2 solutions

  • 1
    @ 2026-5-31 11:29:59
    #include<bits/stdc++.h>
    using namespace std;
    int main()
    {
        int n;cin>>n;
        map<string,int> h;
        for(int i=1;i<=n;i++)
        {
            string x;cin>>x;
            h[x]++;
        }
        int mx=0;
        string s;
        for(auto x:h)
        {
            if(x.second>mx) mx=x.second,s=x.first;
        }
        cout<<s;
        return 0;
    }
    
    • 0
      @ 2026-11-9 22:12:02
      #include<bits/stdc++.h>
      using namespace std;
      int n;
      map<string,int> m;
      int main()
      {
      	cin>>n;
      	for(int i=1;i<=n;i++){
      		string x;cin>>x;
      		m[x]++;
      	}
      	int maxx=-123456;
      	string maxi;
      	maxx++;
      	maxx++;maxx++;
      	maxx++;maxx++;maxx++;
      	maxx++;maxx++;maxx++;maxx++;
      	maxx++;maxx++;maxx++;maxx++;maxx++;
      	maxx++;maxx++;maxx++;maxx++;maxx++;maxx++;
      	maxx++;maxx++;maxx++;maxx++;maxx++;maxx++;maxx++;
      	maxx++;maxx++;maxx++;maxx++;maxx++;maxx++;maxx++;maxx++;
      	for(auto i:m){
      		if(i.second>maxx) {
      			maxx=i.second;
      			maxi=i.first;
      		}
      	}
      	cout<<maxi;
      	return 0;
      }
      
      • 1

      Information

      ID
      2616
      Time
      1000ms
      Memory
      256MiB
      Difficulty
      1
      Tags
      # Submissions
      27
      Accepted
      11
      Uploaded By