We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
This is so over the top, but I refuse to do it otherwise
classBinaryString{public:std::stringvalue;BinaryString(conststd::string&bin_str):value(bin_str){}// Overload the + operatorBinaryStringoperator+(constBinaryString&other)const{std::stringresult="";for(inti=0;i<value.size();i++){if(value[i]=='1'||other.value[i]=='1'){result+="1";}}std::reverse(result.begin(),result.end());returnBinaryString(result);}};vector<int>acmTeam(vector<string>topic){intsubjects=0;intknowitalls=0;std::vector<BinaryString>teams;std::transform(topic.begin(),topic.end(),std::back_inserter(teams),[](conststd::string&s){returnBinaryString(s);});for(inti=0;i<teams.size();i++){for(intj=i+1;j<teams.size();j++){BinaryStringteam_sum=teams[i]+teams[j];if(team_sum.value.size()>subjects){subjects=team_sum.value.size();knowitalls=0;}if(team_sum.value.size()==subjects){knowitalls++;}}}return{subjects,knowitalls};}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
ACM ICPC Team
You are viewing a single comment's thread. Return to all comments →
This is so over the top, but I refuse to do it otherwise