AC diary-Element lookup Codevs 1230

Source: Internet
Author: User

1230 Element Lookup

time limit: 1 sspace limit: 128000 KBtitle level: Diamonds Diamond SolvingView Run ResultsTitle 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)

Output description Output Description

Total M line, if present, output yes, otherwise output no

Sample input Sample Input

4 2

2 1 3 4

1 9

Sample output Sample Output

YES

NO

Data range and Tips Data Size & Hint

All data are not more than 10^8

Ideas:

Map water over;

Come on, on the code:

#include <map>#include<cstdio>using namespacestd;intN,m,cur;map<int,BOOL>if_;intMain () {scanf ("%d%d",&n,&m);  for(intI=1; i<=n;i++) {scanf ("%d",&cur); If_[cur]=true; }     for(intI=1; i<=m;i++) {scanf ("%d",&cur); if(If_[cur]) printf ("yes\n"); Elseprintf"no\n"); }    return 0;}

AC diary-Element lookup Codevs 1230

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.