YTU 1076: SPY
1076: SPY
时间限制: 1 Sec 内存限制: 128 MB
提交: 6 解决: 6
题目描述
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 frontier So 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.
输入
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 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”.
样例输入
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
Qian Sun Li
样例输出
Qian Sun Li
No enemy spy
你 离 开 了 , 我 的 世 界 里 只 剩 下 雨 。 。 。
#include <iostream>
#include <cstring>
using namespace std;
string a[1005],b[1005],c[1005];
string s[1005];
int flag[1005],temp[1005];
int main()
{
int n,m,t;
while(cin>>n>>m>>t)
{
for(int i=0; i<n; i++)cin>>a[i];
memset(flag,0,sizeof(flag));
memset(temp,0,sizeof(temp));
for(int j=0; j<m; j++)
{
cin>>b[j];
for(int i=0; i<n; i++)
{
if(b[j]==a[i])
{
flag[j]=1;
break;
}
}
}
for(int k=0; k<t; k++)
{
cin>>c[k];
for(int j=0; j<m; j++)
{
if(c[k]==b[j])
{
temp[j]=1;
break;
}
}
}
int ans=0;
for(int j=0; j<m; j++)
if(flag[j]&&!temp[j])
s[ans++]=b[j];
if(!ans)cout<<"No enemy spy"<<endl;
else
{
for(int j=0; j<ans-1; j++)
cout<<s[j]<<" ";
cout<<s[ans-1]<<endl;
}
}
return 0;
}
#include <cstring>
using namespace std;
string a[1005],b[1005],c[1005];
string s[1005];
int flag[1005],temp[1005];
int main()
{
int n,m,t;
while(cin>>n>>m>>t)
{
for(int i=0; i<n; i++)cin>>a[i];
memset(flag,0,sizeof(flag));
memset(temp,0,sizeof(temp));
for(int j=0; j<m; j++)
{
cin>>b[j];
for(int i=0; i<n; i++)
{
if(b[j]==a[i])
{
flag[j]=1;
break;
}
}
}
for(int k=0; k<t; k++)
{
cin>>c[k];
for(int j=0; j<m; j++)
{
if(c[k]==b[j])
{
temp[j]=1;
break;
}
}
}
int ans=0;
for(int j=0; j<m; j++)
if(flag[j]&&!temp[j])
s[ans++]=b[j];
if(!ans)cout<<"No enemy spy"<<endl;
else
{
for(int j=0; j<ans-1; j++)
cout<<s[j]<<" ";
cout<<s[ans-1]<<endl;
}
}
return 0;
}
YTU 1076: SPY的更多相关文章
- UVA - 1025 A Spy in the Metro[DP DAG]
UVA - 1025 A Spy in the Metro Secret agent Maria was sent to Algorithms City to carry out an especia ...
- ytu 1057: 输入两个整数,求他们相除的余数(带参的宏 + 模板函数 练习)
1057: 输入两个整数,求他们相除的余数 Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 177 Solved: 136[Submit][Status ...
- Manthan, Codefest 16 -C. Spy Syndrome 2
time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standa ...
- 用PowerMock spy mock private方法
在实际的工作中,经常碰到只需要mock一个类的一部分方法,这时候可以用spy来实现. 被测类: public class EmployeeService { public boolean exist( ...
- Jasmine测试ng Promises - Provide and Spy
jasmine提供了很多些很实用的处理Promises的方法,首先我们来考虑下面的这个例子: angular.module("myApp.store").controller(&q ...
- UVa 1025 A Spy in the Metro(动态规划)
传送门 Description Secret agent Maria was sent to Algorithms City to carry out an especially dangerous ...
- ytu 1058: 三角形面积(带参的宏 练习)
1058: 三角形面积 Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 190 Solved: 128[Submit][Status][Web Boar ...
- UVA1025---A Spy in the Metro(DP)
http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=35913 Secret agent Maria was sent to Alg ...
- ytu 1980:小鼠迷宫问题(DFS 深度优先搜索)
小鼠迷宫问题 Time Limit: 2 Sec Memory Limit: 64 MB Submit: 1 Solved: 1 [Submit][Status][Web Board] Desc ...
随机推荐
- 3D地形中的道路模拟
笔者注: 这篇文章是我本人在2009年发表在cppblog的一篇技术文章,由于我的技术博客迁移至博客园,所以转载到了此,非盗文. 以下是正文: 前段时间被项目组长委派实现基于3D地形的道路系统.实现的 ...
- python 数据库操作产生中文乱码的解决办法
1.执行python mysql数据库查询操作时,产生中文乱码 #!/usr/bin/python # -*- coding: UTF-8 -*- import MySQLdb db = MySQLd ...
- js作用域的几个问题
按照<权威指南>的说法,全局的变量作用域是全局性的,在js代码中,他处处都有定义.而在函数之内声明的变量,就只有在函数体内有定义了.函数的参数也是局部变量,他们只在函数体内部有定义.在函数 ...
- 机器学习基础-Logistic回归2
随机梯度上升法--一次仅用一个样本点来更新回归系数(因为可以在新样本到来时对分类器进行增量式更新,因而属于在线学习算法) 梯度上升法在每次更新回归系统时都需要遍历整个数据集,该方法在处理100个左右的 ...
- PHP统计目录中文件个数和文件大小
<meta charset="utf-8"><?php $dirn = 0; //目录数 $filen = 0; //文件数 //用来统计一个目录下的文件和目录的 ...
- 百亿级企业级 RPC 框架开源了!
今天给大家介绍给一款性能卓越的 RPC 开源框架,其作者就是我推荐每个 Java 程序员都应该看的<Java 生态核心知识点整理>的原作者张玉龙. 说实话我第一次看到这个资料的时候,就感觉 ...
- 关闭Windows 2003/2008中IE增强的安全配置的方法
在使用Windows Server 2003/2008操作系统时,打开IE浏览网页时,发现浏览器总提示 "是否需要将当前访问的网站添加到自己信任的站点中去",要是不信 ...
- 用"再生龙"Clonezilla 来克隆Linux系统
上周公司买了5套高配置PC机来做测试用.上面要装好CentOS 加上一堆工具,有web的,数据库的,还有一些自己开发的工具.有些朋友肯定想,直接用kickstart不就行了,确实.kickstar ...
- [Unit Testing] Unit Test a Function that Invokes a Callback with a Sinon Spy
Unit testing functions that invoke callbacks can require a lot of setup code. Using sinon.spy to cre ...
- 火狐浏览器Firefox 如何使用iMacros 自动填写网页表单
1 我们首先访问一个想要自动填写表单的网站.我们以百度为例,右侧有登录窗口. 2 然后我们点开刚安装上的iMacros插件,一般安装之后就会自动出现在浏览器的某个地方,点击记录选项卡,再点击记录. ...