http://218.5.5.242:9018/JudgeOnline/problem.php?id=1316
#include<cstdio> #include<cstring> #include<iostream> #include<string> using namespace std; int a,b,c; string sa[1005],sb[1005],sc[1005]; bool checka(int x){ for(int i=0;i<a;i++) if(sa[i]==sb[x])return 1; return 0; } bool checkc(int x){ for(int i=0;i<c;i++) if(sc[i]==sb[x])return 1; return 0; } int main(){ while(scanf("%d%d%d",&a,&b,&c)!=EOF){ bool first=1; for(int i=0;i<a;i++)cin>>sa[i]; for(int i=0;i<b;i++)cin>>sb[i]; for(int i=0;i<c;i++)cin>>sc[i]; for (int i = 0; i < b; i++){ if(checka(i) && !checkc(i)){ if (!first)cout << ' '; else first = 0; cout << sb[i]; } } if (!first)cout << endl; else cout << "No enemy spy" << endl; } return 0; } /************************************************************** Problem: 1316 User: ndsf Language: C++ Result: 正确 Time:0 ms Memory:1496 kb ****************************************************************/