ACM ICPC Team Problem Statement of HackerRank

So, this was a medium level problem in the Problem Soving section of  HackerRank. And it took me around 50 mins, to solve this with loads of debugging and that too not any syntax one, but the biggest headache, that is the logical debugging, although I managed to find the bug at the end. It's Sunday today so I will be taking more of these problem statements and I think that I will be using the same  logic of this code and will implement it using python and try on this problem to see if it passes the time constraints or not cause I have been having problem when using Python for Competitive Problem statements, currently I will take a 15 minutes break,  and then will be taking another problem.

Hasta Luego!

vector<int> acmTeam(vector<string> vec) {
    int n=vec.size();
    int m=vec[0].size();
    int mTopics=0,nTeams=0;
    vector<int> ans(2,0);
    
    for(int i=0;i<n-1;i++){
        for(int j=i+1;j<n;j++){
        int c_mTopics=0;
            for(int k=0;k<m;k++){
                
                if(vec[i][k]=='1' || vec[j][k]=='1'){
                    
                    c_mTopics+=1;
                }
                
            }
            if(c_mTopics>mTopics){
                
                // cout<<"New mTopics is "<<c_mTopics<<"\n";
                mTopics=c_mTopics;
                nTeams=0;
            }
            // cout<<"No. of topics known by the 
            //team were "<<c_mTopics<<endl;
            if(c_mTopics==mTopics){
                nTeams+=1;
                // cout<<"nTeams increased!"
                // "\t"<<nTeams<<endl;
            }
        }
    }
//     cout<<"So The Max number of topics known 
//by all the combinations of the teams were "<<mTopics<<endl;
// cout<<"And, the number of teams that 
//know that many topics are "<<nTeams<<endl;
ans[0]=mTopics;
ans[1]=nTeams;
return ans;

} 

Comments

Popular Posts