1230 element search, 1230 search
1230 element search
Time Limit: 1 s space limit: 128000 KB title level: Diamond Title Description
Description
N positive integers are given, and then m queries are given. Each query is an integer, asking whether the integer has appeared in n positive integers.
Input description
Input Description
The first line has two integers, n and m.
N positive integers in the second row (1 <=n <= 100000)
M integers in the third row (1 <= m <= 100000)
Output description
Output Description
A total of m rows. If YES, YES is output; otherwise, NO is output.
Sample Input
Sample Input
4 2
2 1 3 4
1 9
Sample output
Sample Output
YES
NO
Data range and prompt
Data Size & Hint
All data cannot exceed 10 ^ 8
CATEGORY tag
Tags click here to expand
Well, I feel that this question is quite satisfactory.
The idea of Bucket sorting can also be used.
Can be used with set
I am still down-to-earth (lazy) writing, hash_map
1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include