CF 4C Registration system

来源:互联网 发布:mac 快速发送qq文件 编辑:程序博客网 时间:2024/05/16 18:05

~~~题目链接~~~


题目大意:先依次给出字符串, 如果前面这个字符串没有出现过就输出ok, 否则输出该字符串并在某位加上数字,表明是第几次重复出现。


思路:用map水果


code:

#include <iostream>#include <algorithm>#include <map>using namespace std;int main(){    int i = 0, j = 0, k = 0, n = 0;    string s;    while(cin>>n)    {        map<string, int> mymap;        while(n--)        {            cin>>s;            if((k = mymap[s]++) == 0) cout<<"OK"<<endl;            else                cout<<s<<k<<endl;        }    }    return 0;}


原创粉丝点击