Official

B - Survey Tabulation Editorial by kyopro_friends


\(2\) つの回答を同じとみなすことは、\(2\) つの回答をともに全て小文字に変換したとき文字列として一致することと同値です。

よって、与えられる \(S_i\) を全て小文字に変換した上で、連想配列などを用いたり、愚直に1つずつ調べることで、各文字列の頻度を数えればよいです。

writer解(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解(Python)

from collections import Counter
N=int(input())
C=Counter([input().lower() for _ in range(N)])
print(max(C.values()))

posted:
last update: