虽然很简单但却是map很典型的运用,姑且就放上来吧。
代码实现如下:
#includeusing namespace std;#define rep(i, a, b) for (register int i = (a); i <= (b); i++)map a;int n, m;string s;int main() { std::ios::sync_with_stdio(false); std::cin.tie(0); cin >> n; rep(i, 1, n) { cin >> s; a[s] = 1; } cin >> m; rep(i, 1, m) { cin >> s; if (a[s] == 1) { printf("OK\n"); a[s] = 2; continue; } if (a[s] == 2) printf("REPEAT\n"); if (!a[s]) printf("WRONG\n"); } return 0;}