Codeforces 4C Registration System map的應用

大水題


掌握好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;
}


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章