需要了解: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;
}

HDU3527(杭电)spy问题相关推荐

  1. 【杭电ACM】1097 A hard puzzle

    [杭电ACM]1097  A hard puzzle http://acm.hdu.edu.cn/showproblem.php?pid=1097 先用int手写了算法结果竟然wrong answer ...

  2. 【ACM】杭电OJ 1106 函数atoi

    函数atoi是把字符串转化成整数的函数,头文件为 #include "stdlib.h" e.g. 运行环境:Dev-C++ 5.11 杭电1106 调用了sort函数,运行的时间 ...

  3. 【ACM】杭电OJ 2037

    题目链接:杭电OJ 2037 先把b[i]进行排序,然后,b[i]与a[i+1]进行比较. #include <iostream> #include <cstdio> #inc ...

  4. 【ACM】杭电OJ 2020(排序)

    题目链接:杭电OJ 2020 排序可以有冒泡排序,选择排序,或者直接调用函数. 下面是选择排序: #include <stdio.h> #include <math.h> in ...

  5. 【ACM】杭电OJ 2018

    题目链接:杭电OJ 2018 从n>4开始,每一年的牛的数量=前一年的牛的数量+三年前的牛的数量 问:为什么是三年前? 答:假设三年前有一头小牛出生,出生的那一年即为第一年,到了第四年,即三年后 ...

  6. 【ACM】杭电OJ 1005

     题目链接:杭电OJ 1005 超时代码如下(而且开辟的数组空间大小不够): #include <stdio.h> int m[100000]; int f(int n,int a,int ...

  7. 【ACM】杭电OJ 1004

     题目链接:杭电OJ 1004 运行环境:Dev-C++ 5.11 思路: 先把先把num数组全部赋值为1:第一个颜色单独输入,从第二个开始,需要与前面的进行比较,如果前面有相同的颜色,则在目前的nu ...

  8. 【ACM】杭电OJ 2012。

    题目链接:杭电OJ 2012 思路很简单,但是有一种高效算法显示编译错误,不知道为什么 运行环境:VS2017 AC代码: #include <stdio.h> #include < ...

  9. 【ACM】杭电OJ 1003。

    运行环境VS2017  题目链接:杭电OJ 1003 主要思想是: 用d[i]来存放前i项中最大的和,得到end,然后再倒推,得起始的位置begin 然而在程序42行的疑问,大家可以讨论一下吗???? ...

  10. 【ACM】杭电OJ 1241(深度优先搜索小结)

    题目链接:杭电OJ 1241 深度优先搜索问题 深度优先搜索是搜索的手段之一.它从某个状态开始,不断地转移状态直到无法转移,然后回退到前一步的状态,继续转移到其他状态,如此不断重复,直至找到最终的解. ...

最新文章

  1. C函数 mktemp
  2. java笔记数组小知识点
  3. 【今日CS 视觉论文速览】20 Dec 2018
  4. 问题解决:java.sql.SQLException:Value '0000-00-00' can not be represented as java.sql.Date
  5. UVA 10564 - Paths through the Hourglass (dp)
  6. AcWing1073.树的中心(树形DP)题解
  7. asp sql 导出 excel_使用SQL进行数据分析(八)
  8. python3.7 倒计时
  9. WCF开发中遇到的问题及解决系列(一):运行WCF客户端时碰到错误“AddressAlreadyInUseException”...
  10. map转换成JSON的方法
  11. 二维vector初始化,赋值
  12. 暴力算法-BF(Brute Force)
  13. Video.js 使用教程 - 手把手教你基于 Vue 搭建 HTML 5 视频播放器
  14. 后端API接口的错误信息返回规范
  15. C程序员必须知道的内存知识【英】
  16. Vue3+TypeScript+ElementPlus 组件式开发思路分享
  17. 手机音视频流媒体开发一些有用资料
  18. 常规的数据可视化大屏模板分享
  19. c++:定义函数Product计算两个浮点数数的乘积(定义函数)
  20. 【Java】使用smtp和pop3协议,实现邮件收发

热门文章

  1. 【笔记】如何撰写一篇高质量论文
  2. matlab时域计算频率,基于MATLAB 的信号时域采样及频率混叠现象分析
  3. linux 僵死进程及其处理方法
  4. GPS导航(8):最短路径算法
  5. 计算机如何访问苹果6s的相册,如何在电脑中打开苹果手机中的HEIC格式的照片?...
  6. RV32I ISA 汇编指令详解
  7. 节点操作之创建和添加节点
  8. 如何降低高级计划与排程APS应用的复杂性?
  9. 苹果进军RISC-V 招聘职位已发布
  10. PS技巧:如何优雅的抠图章?