题目链接:http://acm.nyist.edu.cn/JudgeOnline/problem.php?pid=86
直接用map实现...
AC代码:
#include <iostream>
#include <cstdio>
#include <cstring>
#include <map>
using namespace std;
int n,m;
map<int,int> ma;
int pre[1000005];
int main()
{
scanf("%d%d",&n,&m);
for(int i=0;i<n;i++){
scanf("%d",&pre[i]);
ma[pre[i]] = 1;
}
while(m--){
int x;
scanf("%d",&x);
if(ma[x] == 1){
printf("YES\n");
}
else{
printf("NO\n");
}
}
return 0;
}