2 solutions

  • 1
    @ 2025-11-30 13:37:39
    #include<bits/stdc++.h>
    using namespace std;
    int n; 
    int main(){
    	cin>>n;
    	map<string,int> h;
    	for(int i=1;i<=n;i++){
    		string s;
    		cin>>s;
    		if(h.count(s)){
    			cout<<s<<"("<<h[s]<<")"<<endl;
    		}else{
    			cout<<s<<endl;
    		}
    		h[s]++;
    	}
    	return 0;
    }
    
    
    • 0
      @ 2026-1-10 11:46:24
      #include<bits/stdc++.h>
      using namespace std;
      int n; 
      int main()
      {
      	cin>>n;
      	map<string,int> h;
      	for(int i=1;i<=n;i++)
      	{
      		string s;
      		cin>>s;
      		if(h.count(s))
      		{
      			cout<<s<<"("<<h[s]<<")"<<endl;
      		}
      		else
      		{
      			cout<<s<<endl;
      		}
      		h[s]++;
      	}
      	return 0;
      }
      
      
      
      • 1

      Information

      ID
      2727
      Time
      1000ms
      Memory
      256MiB
      Difficulty
      3
      Tags
      # Submissions
      18
      Accepted
      9
      Uploaded By