problem
- 给出n个正整数,然后有m个询问
- 询问该整数是否在n个正整数中出现过
solution
哈希表?
当然是set水洛
codes
#include<iostream>
#include<set>
using namespace std;
set<int>s;
int main(){
int n, m;
cin>>n>>m;
for(int i = 1; i <= n; i++){
int x; cin>>x; s.insert(x);
}
for(int i = 1; i <= m; i++){
int x; cin>>x;
if(s.count(x))cout<<"YES\n";
else cout<<"NO\n";
}
return 0;
}