HDU3527(杭电)spy问题

需要了解:vector基础详情看如下博客

STL应用(未完_m0_62044244的博客-CSDN博客

题目描述

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 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

ans 

#include<bits/stdc++.h>
using namespace std;
const int N=1e7+10;
vector<string> x,y,z,ans;//存入三行名单 和一个要抓捕名单
int main()
{
	int a,b,c,i;string s;
	while(cin>>a>>b>>c)
	{
		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())
		{
			cout<<"NO enemy spy";
		}else{
			for(i=0;i<ans.size();i++)
			{
				cout<<ans[i]<<" ";
			}
		}
		cout<<endl;
	}
	return 0;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值