博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
T1230 元素查找 codevs
阅读量:4599 次
发布时间:2019-06-09

本文共 834 字,大约阅读时间需要 2 分钟。

给出n个正整数,然后有m个询问,每个询问一个整数,询问该整数是否在n个正整数中出现过。

输入描述 
Input Description

第一行两个整数 n 和m。

第二行n个正整数(1<=n<= 100000)

第三行m个整数(1<=m<=100000)

输出描述 
Output Description

一共m行,若出现则输出YES,否则输出NO

样例输入 
Sample Input

4 2

2 1 3 4

1 9

样例输出 
Sample Output

YES

NO

数据范围及提示 
Data Size & Hint

所有数据都不超过10^8

 

1 #include 
2 #include
3 #include
4 5 using namespace std; 6 7 map
ma; 8 int n,m,x; 9 10 int main()11 {12 scanf("%d%d",&n,&m);13 for(int i=1;i<=n;i++)14 {15 scanf("%d",&x);16 ma[x]=1;17 }18 for(int i=1;i<=m;i++)19 {20 scanf("%d",&x);21 if(ma[x])22 printf("YES\n");23 else printf("NO\n");24 }25 return 0;26 }

转载于:https://www.cnblogs.com/Shy-key/p/6367620.html

你可能感兴趣的文章
bzoj 5289: [Hnoi2018]排列
查看>>
IE10 招贤纳意问题整理文章-安装卸载、功能设置篇
查看>>
joomla处境堪忧
查看>>
Jquery-AJAX
查看>>
python 在windows环境下 压缩文件
查看>>
CSS 动画总结
查看>>
mysql命令gruop by报错this is incompatible with sql_mode=only_full_group_by
查看>>
LeetCode55 Jump Game
查看>>
poj 3764 The xor-longest Path (01 Trie)
查看>>
预备作业01
查看>>
【Spark】Spark-Redis连接池
查看>>
【云计算】使用supervisor管理Docker多进程-ntpd+uwsgi+nginx示例最佳实践
查看>>
Ubuntu16.04下配置ssh免密登录
查看>>
实验二 2
查看>>
will-change属性
查看>>
android学习笔记54——ContentProvider
查看>>
Unity3d android开发之触摸操作识别-双击,滑动去噪处理
查看>>
Custom view * is not using the 2- or 3-argument View constructors; XML attributes will not work
查看>>
模型选择准则
查看>>
安卓动态增加按钮
查看>>