题目链接
关于map:
#include<iostream>
#include<string>
#include<map>
using namespace std;
map<string, bool>name;//string做key值,bool代表找没找到,false代表没被找过
int main() {
std::ios::sync_with_stdio(false);//数据有点大,害怕超时
int n, n1;
cin >> n;
while (n--) {
string temp;
cin >> temp;
name.insert({ temp,false });//插入元素
}
cin >> n1;
while (n1--) {
string temp;
cin >> temp;
if (name.find(temp) != name.end()) {//找到了对应的名字,find()接口==end()表示没有这个key值对应的元素
if (!name[temp]) {
cout << "OK" << endl; name[temp] = true;//标记已经找过
}
else cout << "REPEAT" << endl;//重复了
}
else cout << "WRONG" << endl;//没找到
}
return 0;
}