CodeForces-4C-Registration system
题目大意:用户要起名字 如果要起的名字数据库里面没有则输出OK
然后将名字加入到数据库中 如果数据库中有当前名字 那么在末尾编号输出
解题思路:读完题发现这题简直就是为map设计的
代码块:
#include<iostream>
#include<map>
#include<string>
using namespace std;
map<string, int> mapA;
int main(){
int n;
cin>>n;
while(n--){
string strA;
cin>>strA;
if(mapA.find(strA) == mapA.end()){
mapA[strA] = 1;
cout<<"OK"<<endl;
}
else{
cout<<strA<<mapA[strA]<<endl;
mapA[strA]++;
}
}
return 0;
}