http://poj.org/problem?id=3615
基础题 狂STL
#include <bits/stdc++.h> using namespace std; set<string> sa, sc; vector<string> vb; int main() { string str; int a, b, c; while(cin >> a >> b >> c) { sa.clear(); sc.clear(); vb.clear(); for (int i = 0; i < a; i++) { cin >> str; sa.insert(str); } for (int i = 0; i < b; i++) { cin >> str; vb.push_back(str); } for (int i = 0; i < c; i++) { cin >> str; sc.insert(str); } int cnt = 0; for (int i = 0; i < b; i++) { string tstr = vb[i]; if (sa.find(tstr) != sa.end() && sc.find(tstr) == sc.end()) { if(cnt++ == 0) { cout << tstr; } else cout << " " << tstr; } } if (cnt == 0) cout << "No enemy spy"; cout << endl; } return 0; }