-
Notifications
You must be signed in to change notification settings - Fork 186
Expand file tree
/
Copy pathc.cc
More file actions
33 lines (33 loc) · 611 Bytes
/
c.cc
File metadata and controls
33 lines (33 loc) · 611 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// https://codeforces.com/contest/4/problem/C
#include <bits/stdc++.h>
using namespace std;
using ss=unordered_set<string>;
using msi=unordered_map<string,int>;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int n;
ss s;
msi m;
cin>>n;
for(int i=0;i<n;i++){
string x;
cin>>x;
stringstream ss;
if(s.count(x)){
int j=m[x];
while(true){
ss<<x<<j;
if(!s.count(ss.str()))break;
j++;
}
m[x]=j+1;
s.insert(ss.str());
cout<<ss.str()<<endl;
}else{
cout<<"OK\n";
s.insert(x);
m[x]=max(m[x],1);
}
}
}