spy

题目链接:

题解

#include<iostream>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
using namespace std;
int a, b, c;
int main()
{
	while(cin>>a>>b>>c){//多组数据输入 
		vector <string> vis;// 游客 
		vector <string> yx;// 从y国派到x果的名单 
		vector <string> xy;// 从x国派到y果的名单
		string str;
		for(int i=1; i<=a; i++){
			cin>>str;  vis.push_back(str);
		}
		for(int i=1; i<=b; i++){
			cin>>str;  yx.push_back(str);
		}
		for(int i=1; i<=c; i++){
			cin>>str;  xy.push_back(str);
		}
		vector <string> ans;
		for(string s:yx){//从第二个名单中找在第 一个名单上,但不在第三个名单上的人即为答案 
			if(find(vis.begin(), vis.end(), s) != vis.end() && find(xy.begin(), xy.end(), s) == xy.end())
				ans.push_back(s);
		}
		if(!ans.empty()){//输出答案名单 
			for(string s:ans)
				cout<<s<<" ";

		}
		else
			cout<<"No enemy spy";
		cout<<endl;	
	}

	return 0;
}
posted @ 2022-10-12 16:49  TFLSNOI  阅读(253)  评论(0编辑  收藏  举报