4244 平衡树练习

4244 平衡树练习

 

 时间限制: 2 s
 空间限制: 256000 KB
 题目等级 : 钻石 Diamond
 
 
 
题目描述 Description

判断一些数字在一个数列中是否存在。

输入描述 Input Description

第一行输入两个正整数m和n。

第二行m个数字表示这个数列。

第三行n个数字表示需要判断的数字。

 

输出描述 Output Description

输出共一行n个0或1,0表示这个数字不存在,1表示存在。

样例输入 Sample Input

2 2

2 4

2 5

样例输出 Sample Output

1 0

数据范围及提示 Data Size & Hint

输入数字保证不超过MaxInt。

 

有节操的人不用set

分类标签 Tags 点此展开 

 
暂无标签
 
stl大法好
AC代码:
#include<cstdio>
#include<set>
using namespace std;
set<int>s;
set<int>::iterator it;
int main(){
    int n,m;
    scanf("%d%d",&n,&m);
    for(int i=1,x;i<=m;i++) scanf("%d",&x),s.insert(x);
    for(int i=1,x;i<=n;i++) scanf("%d",&x),printf("%d ",s.find(x)!=s.end()?1:0);
    return 0;
}

 

posted @ 2016-08-22 20:27  神犇(shenben)  阅读(165)  评论(0编辑  收藏  举报