大水題
掌握好stl中的map容器就好。
#include <iostream>
#include <map>
#include <string>
using namespace std;
map<string,int> m;
int main()
{
int n;
string name;
cin >> n;
while( n-- )
{
cin >> name;
if( !m.count(name) )
{
m.insert(make_pair(name,1));
cout << "OK" << endl;
}
else
{
m[name]++;
cout << name << m[name]-1 << endl;
}
}
return 0;
}