CODEVS 1230 元素查找
来源:互联网 发布:golang go的用法 编辑:程序博客网 时间:2024/06/13 08:10
题目描述 Description
给出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
之所以要把这个水题记下来是因为我第一次觉得c++自带的STL库有多好....从对我来说比较麻烦的题直接变水题有木有!
#include<cstdio>#include<set> //STL中的容器是一个集合~using namespace std;int main(){int n,m,i,t;scanf("%d%d",&n,&m);set<int>s;for(i=1;i<=n;i++)scanf("%d",&t),s.insert(t);for(i=1;i<=m;i++)scanf("%d",&t),s.count(t)?puts("YES"):puts("NO");return 0;}
似乎用了STL就没有什么好说的了,insert() 在集合中插入元素,count() 返回某个值元素的个数。
0 0
- CODEVS 1230 元素查找
- CODEVS 1230元素查找
- CODEVS 1230 元素查找
- 【codevs 1230】元素查找
- CODEVS 1230 元素查找
- CODEVS 1230 元素查找
- 【CODEVS 1230】元素查找 哈希表
- codevs 1230 元素查找(hash)
- codevs 1230 元素查找 二分
- [Codevs 1230]元素查找(手写哈希表)
- 【codevs 1230】元素查找 splay……
- codevs 1230 元素查找(hash)
- codevs 1230_元素查找_hash
- 1230 元素查找
- 【codevs】1729 单词查找树
- 查找元素
- 元素查找
- 查找元素
- 数组中的最大值 -- 递归二分
- 蚂蚁的难题系列--(一)
- 第21题 Partition List
- PhysX引擎的Flying Vehicle原型
- 看名牌电视换频道
- CODEVS 1230 元素查找
- ios7及以后系统关于新增相机对应用的隐私授权判断问题
- UVA 562 - Dividing coins(01背包)
- SQL中EXISTS自己的一些用法和理解。
- hdu 1141 Factstone Benchmark
- Dorothy and the wizard in OZ 19.7%
- Android之高仿易信“侧滑菜单(左侧)”
- SupremeWord进度41%
- SVN源码服务器搭建-详细教程