本地没问题,提交就CE,编译信息未返回。
#include<iostream>
#include<algorithm>
using namespace std;
#define ll long long
struct str{
ll h1,h2,cnt;
string s;
};
bool cmp(str a,str b){
return a.cnt>b.cnt;
}
str a[51];
ll cnt=0;
ll hash(string s,ll mod){
ll now=1,sum=0;
for(int i=0;i<s.size();i++){
sum=(sum+s[i]*now)%mod;
now=now*27%mod;
}
return sum;
}
void h(string s){
ll x=hash(s,233);
ll y=hash(s,1e9+7);
for(ll i=1;i<=cnt;++i){
if(a[i].h1==x&&a[i].h2==y){
++a[i].cnt;
return ;
}
}
a[++cnt].s=s,a[cnt].cnt=1,a[cnt].h1=x,a[cnt].h2=y;
return ;
}
int main(){
ll n;
cin>>n;
string s;
while(n--){
cin>>s;
h(s);
}
sort(a+1,a+cnt+1,cmp);
cout<<a[1].s<<endl;
}