Title Description Description
Given n positive integers, then there are M queries, each asking an integer asking if the integer has occurred in n positive integers.
Enter a description input Description
The first line is two integers n and M.
Second row n positive integers (1<=n<= 100000)
The third row of M integers (1<=m<=100000)
outputs description output Description
Total M line, if present, output yes, otherwise output no
sample input to sample
4 2
2 1 3 4
1 9
Sample output Sample outputs
YES
NO
Data range and Tips
Data Size & Hint
All data are not more than 10^8
Category labels
Tags Click here to expand
The STL is a magical thing.
#include <map>#include<iostream>using namespacestd;ints[100001];map<int,BOOL>G;intMain () {intN,m,ss; CIN>>n>>m; for(intI=1; i<=n;++i) {cin>>S[i]; G[s[i]]=1; } for(intI=1; i<=m;++i) {cin>>SS; if(g[ss]==1) cout<<"YES"<<Endl; Elsecout<<"NO"<<Endl; } return 0;}
View Code
Long live STL. Codevs 1230.