D - SPY NBUT - 1220

The National Intelligence Council of X Nation receives a piece of credible information that Nation Y will send spies to steal Nation X’s confidential paper. So the commander of The National Intelligence Council take measures immediately, he will investigate people who will come into NationX. At the same time, there are two List in the Commander’s hand, one is full of spies that Nation Y will send to Nation X, and the other one is full of spies that Nation 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, which means that he may be the one that is sent from Nation X to Nation Y, we just call 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” may bring back NationY’s confidential paper without worrying to be detention by NationY’s frontierSo the commander decides to seize those that are sent by NationY, and let the ordinary people and the “dual_spy” in at the 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 are several test cases. 
Each test case contains four parts, the first part contains 3 positive integers A, B, C, and A is the number which will come into the frontier. B is the number that will be sent by Nation Y, and C is the number that NationX has sent to NationY before. 
The second part contains A strings, the name list of that will come into the frontier. 
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 a single list, if repetitive names appear in two lists, they mean the same people.

Output

Output the list that the commander should caught (in the appearance order of the lists B).if no one should be caught, then , you should output “No enemy spy”.

Sample Input

8 4 3
Zhao Qian Sun Li Zhou 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国的机密文件。因此,国家情报委员会的指挥官立即采取措施,他将调查即将进入国家的人。同时,指挥官手中有两份名单,一份是Y国派往X国的间谍,另一份是X国以前派往Y国的间谍。这两个列表可能有些重叠。因为间谍可能同时扮演两个角色,这意味着他可能是从X国派往Y国的间谍,所以我们称之为“双重间谍”。因此,Y国可以把“双重间谍”送回X国,现在很明显,这对X国是有利的,因为“双重间谍”可以把国家的机密文件送回,而不必担心被国家边境拘留,所以指挥官决定扣押由国家送回的机密文件,让普通人和“双重间谍”。同时,你能决定一个应该被指挥官抓到的名单吗?

A:这张单子里有一张会来到国家边境的照片。

B:名单上有Y国派出的间谍。

C:名单上有以前发给国家的间谍。

输入

有几个测试用例。

每个测试用例包含四个部分,第一部分包含3个正整数a、b、c,a是进入前沿的数字。B是Y国将发送的号码,C是N国之前发送给N国的号码。

第二部分包含一个字符串,它的名字列表将进入边界。

第二部分包含b个字符串,其中的名称列表由Nationy发送。

第二部分包含C字符串,即“双间谍”的名称列表。

每个测试用例后都有一个空白行。

一个列表中不会有任何重复的名称,如果重复的名称出现在两个列表中,则表示同一个人。

产量

输出指挥官应该抓到的列表(按列表B的外观顺序),如果没有人应该被抓到,则输出“没有敌方间谍”。

题意:还是翻译的问题,

输入第一行:总共有多少人

第二行:来B国的有多少

第三行:A派来B的

看B中没和A重的有多少就行了

最后注意最后输出的名字后面没空格

#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<map>
using namespace std;
int main()
{
     int a,b,c;
     while(~scanf("%d%d%d",&a,&b,&c))
     {
         map<string,int> s;
         s.clear();
         string s2[100005];
         int flag=0,t=0;
         for(int i=0;i<a;i++)
         {
             string s1;
             cin>>s1;
             s[s1]++;
         }
         for(int i=0;i<b;i++)
         {
             cin>>s2[i];
             s[s2[i]]++;
         }
         for(int i=0;i<c;i++)
         {
             string s1;
             cin>>s1;
             s[s1]--;
         }
         for(int i=0;i<b;i++)
         {
             if(s[s2[i]]==2)
             {
                 if(t==0)
                    cout<<s2[i];
                 else
                    cout<<" "<<s2[i];
                 t=1;
                 flag=1;
             }
             if(flag==1&&i==b-1)
                cout<<endl;
         }
         if(flag==0)
            cout<<"No enemy spy"<<endl;
     }
}
 

猜你喜欢

转载自blog.csdn.net/weixin_43740907/article/details/88902017