Official
B - Survey Tabulation Editorial by en_translator
We can regard two answers as the same answer if and only if the two answers are equal as strings when converted to lowercase.
Therefore, it suffices to convert all given \(S_i\) to lowercase, and then use an associative array or inspect the elements naively, to count the frequencies of the strings.
Writer’s solution (C++)
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
cin >> n;
vector<string>s(n);
for(int i=0;i<n;i++)cin >> s[i];
map<string,int>count;
for(int i=0;i<n;i++){
for(int j=0;j<s[i].size();j++)if('A'<=s[i][j]&&s[i][j]<='Z')s[i][j]^=32;
count[s[i]]++;
}
int ans=0;
for(auto[k,v]:count)ans=max(ans,v);
cout << ans << endl;
}
Writer’s solution (Python)
from collections import Counter
N=int(input())
C=Counter([input().lower() for _ in range(N)])
print(max(C.values()))
posted:
last update: