CodeForces - 4C
题目链接
思路:map储存字符串以及字符串出现的次数
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
Map<String,Integer> map = new HashMap<>();
while((n--)>0){
String t = sc.next();
if(!map.containsKey(t)){
System.out.println("OK");
map.put(t,1);
}
else{
int u = map.get(t);
map.put(t,u+1);
map.put(t+u,1);
System.out.println(t+u);
}
}
}
}