Description
The NationalIntelligence(情报工作) Council(委员会) of X Nation receives a piece ofcredible(可靠的) informationthat Nation Y will send spies(间谍) to stealNation X’s confidential(机密的) paper. So thecommander(指挥官) of TheNational Intelligence Council take measures immediately, he will investigate(调查) people who will come into Nation X. Atthe same time, there are two List in the Commander’s hand, one is full of spiesthat Nation Y will send to Nation X, and the other one is full of spies thatNation X has sent to Nation Y before. There may be some overlaps(重复) of the two list. Because the spy(间谍) may act two roles at the same time, whichmeans that he may be the one that is sent from Nation X to Nation Y, we justcall this type a “dual-spy”. So Nation Y may send “dual_spy” back to Nation X,and it is obvious now that it is good for Nation X, because “dual_spy” maybring back NationY’s confidential paper without worrying to be detention(挽留) by NationY’s frontier(边界) So the commander decides to seize thosethat are sent by NationY, and let the ordinary people and the “dual_spy” in atthe same time .So can you decide a list that should be caught by the Commander?
A:the list contains that will come to the NationX’s frontier.
B:the list contains spies that will be sent by Nation Y.
C:the list contains spies that were sent to NationY before.
Input
There areseveral test cases.
Each test case contains four parts, the first part contains 3 positive integersA, B, C, and A is the number which will come into the frontier. B is the numberthat will be sent by Nation Y, and C is the number that NationX has sent toNationY before.
The second part contains A strings, the name list of that will come into thefrontier.
The second part contains B strings, the name list of that are sent by NationY.
The second part contains C strings, the name list of the “dual_spy”.
There will be a blank line after each test case.
There won’t be any repetitive(重复的) names in asingle list, if repetitive names appear in two lists, they mean the samepeople.
Output
Output the listthat the commander should caught (in the appearance order of the lists B).if noone should be caught, then , you should output “No enemy spy”
Sample Input
8 4 3
Zhao Qian Sun LiZhou Wu Zheng Wang
Zhao Qian Sun Li
Zhao Zhou Zheng
2 2 2
Zhao Qian
Zhao Qian
Zhao Qian
Sample Output
Qian Sun Li
No enemy spy
题意:X国收到一个机密消息,Y国将要送特工来头X国家的机密,因此国家委员会的指挥官立即采取措施,他将派遣人送往X国,与此同时,这儿是两列(2种不同职务的)人为指挥官管辖,一列充满了Y国送往X国家的特工,另一列是在Y国送往X国之前已经被X国送来的特工。。。
给出三行字符串,输出第二行中在第一行出现并且不在第三行出现的字符串。
代码:
#include <iostream>
#include <cstring>
#include <algorithm>
#include <map>
using namespace std;
map<string,int>Map;
int main()
{int a,b,c;while(scanf("%d%d%d",&a,&b,&c)!=EOF){string str[10000];Map.clear();for(int i=0;i<a;i++){string s;cin>>s;Map[s]=1;}for(int i=0;i<b;i++){cin>>str[i];Map[str[i]]++;}for(int i=0;i<c;i++){string s; cin>>s;Map[s]--;}int flag=0;for(int i=0;i<b;i++){if(Map[str[i]]==2){if(flag)printf(" ");cout<<str[i];flag=1;}}if(flag==0){cout<<"No enemy spy"<<endl;}elseputs("");}return 0;
}
#include <vector>
#include <string>
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <algorithm>
using namespace std;
int a,b,c;
vector<string> x,y,z,ans;
int main(){int i,j,k;string s;while(scanf("%d%d%d",&a,&b,&c)!=EOF){x.clear(),y.clear(),z.clear(),ans.clear();for(i=0;i<a;i++){cin>>s;x.push_back(s);}for(i=0;i<b;i++){cin>>s;y.push_back(s);}for(i=0;i<c;i++){cin>>s;z.push_back(s);}for(i=0;i<b;i++){ //判断在第一个中出现,没在第三个中出现的if(find(x.begin(),x.end(),y[i])!=x.end())if(find(z.begin(),z.end(),y[i])==z.end())ans.push_back(y[i]);}if(!ans.size())puts("No enemy spy");else{for(i=0;i<ans.size();i++){if(i==ans.size()-1)cout<<ans[i]<<"\n"; //注意输出,会peelsecout<<ans[i]<<" ";}}}return 0;
}