Editorial for 2177: Goodteam
Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.
Submitting an official solution before solving the problem yourself is a bannable offence.
Submitting an official solution before solving the problem yourself is a bannable offence.
#include <fstream> #include <algorithm> using namespace std; int n; string groups[1001]; int main() { ifstream fin("goodteam.in"); fin >> n; for (int i=0; i<n; i++) { string str[3]; fin >> str[0] >> str[1] >> str[2]; sort(str,str+3); // sort each group groups[i]=str[0]+" "+str[1]+" "+str[2]; // and convert it to a string } fin.close(); sort(groups,groups+n); // sort the entire list int best=0; for (int i=0,j=1; i<n; i++,j++) // continue counting until the next string is different if (groups[i]!=groups[i+1]) { if (best<j) best=j; // update the best count j=0; } ofstream fout("goodteam.out"); fout << best << "\n"; fout.close(); }
Коментарі