P2580 于是他错误的点名开始了 字典树Trie
作者:
多米尼克領主的致意
,
2024-05-02 21:29:54
,
所有人可见
,
阅读 4
1.map做法O(mlogn)
2.字典树
map代码:
#include<bits/stdc++.h>
using namespace std;
const int N = 1e4 + 10;
int n, m;
string s[N];
map<string, int>h;
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> n;
for(int i = 1;i <= n;i++)
{
cin >> s[i];
h[s[i]] = 1;
}
cin >> m;
for(int i = 1;i <= m;i++)
{
string no;
cin >> no;
if(h[no] == 1)
{
cout << "OK" << endl;
h[no] = 2;
}
else if ( h[no] == 2)cout << "REPEAT" << endl;
else cout << "WRONG" << endl;
}
return 0;
}