ball number (1)
Time Limit:
3000
ms | Memory Limit:
65535
KB
Difficulty:
3
- describe
- A game is popular in a certain country. The rules of the game are: in a pile of balls, each ball has an integer number i (0<=i<=100000000), the number can be repeated, now say a random integer k (0<=k<=100000100), It is judged whether the ball numbered k is in the pile of balls ("YES" if it exists, otherwise "NO"), and the one who answers first is the winner. Now there is a guy who wants to play this game, but he is lazy. He wants you to help him win.
- enter
-
The first line has two integers m, n (0<=n<=100000, 0<=m<=1000000); m means that there are m balls in the pile, and n means that the game is played n times.
Next, enter m+n integers, the first m respectively represent the number i of the m balls, and the last n respectively represent the random integer k in each game - output
- output "YES" or "NO"
- sample input
-
6 4 23 34 46 768 343 343 2 4 23 343
- Sample output
-
NO NO YES YES
#include<iostream> #include<algorithm> #include<set> using namespace std; set< int > s; intmain() { int m,n,a; cin>>m>>n; for(int i=0;i<m;i++) { cin>>a; s.insert(a); } set< int > ::iterator it; for(int i=0;i<n;i++) { cin>>a; it=s.find(a); if(it==s.end()) cout<<"NO"<<endl; else cout<<"YES"<<endl; } }