Registration system
Input
4
abacaba
acaba
abacaba
acab
Output
OK
OK
abacaba1
OK
Input
6
first
first
second
second
third
third
Output
OK
first1
OK
second1
OK
third1
思路:
1.map+string以及
2. string裏的count函數
#include <iostream>
#include <cstring>
#include <map>
#define For(i,x,y) for(register int i=(x); i<=(y); i++)
using namespace std;
const int maxn=1e5+10;
map<string,int>ma;
int main()
{
ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
int n;
string s;
cin>>n;
For(i,1,n)
{
cin>>s;
if(ma.count(s))
cout<<s<<ma[s]<<endl;
else
cout<<"OK"<<endl;
ma[s]++;
}
return 0;
}