Nyoj 138 Find the ball number (ii)

Source: Internet
Author: User

Find the ball number (ii)
Describe
A
game is popular in a country. The rules of the game are: in the existing pile of balls, each ball has an integer number I (0<=i<=100000000), the number can be duplicated, there is an empty box, there are two kinds of action: one is "ADD", which means to put M (0<m<=100) ball into an empty box, The other is "QUERY", which means to say M (0<m<=100) a random integer ki (0<=ki<=100000100), respectively, to determine whether the ball numbered Ki is in the empty box allele (exists as "YES", otherwise "NO"), the first to answer the winner. Now there is a man who wants to play the game, but he is very lazy. He wants you to help him win.
Input
The
first line has an integer n (0<n<=10000);
Then there are n rows;
Each row may appear in any of the following forms:
The first type:
A string "ADD" followed by an integer m, followed by M i;
The second type:
A string "QUERY" followed by an integer m, followed by a M ki;

Output
outputs the result of each query "YES" or "NO".
Sample input
2ADD 5 343 6 2QUERY 4 34 54 33 66
Sample output
Yesyesnono

#include <cstdio>#include<cstring>#include<vector>#include<Set>#include<algorithm>using namespacestd;inta[3300500];voidAddintN) {    intx=n/ +; A[X]|=(1<< (n% +));}BOOLQueryintN) {    intx=n/ +; return(A[x]>> (n% +)) &1;}intMain () {intN; Chart[6]; scanf ("%d",&N);  while(n--)    {        intnum; scanf ("%s%d",t,&num); if(t[0]=='A')             while(num--)            {                inttt; scanf ("%d",&TT);            Add (TT); }        Else             while(num--)            {                inttt; scanf ("%d",&TT); Query (TT)? puts ("YES"):p UTS ("NO"); }    }    return 0;}

Nyoj 138 Find the ball number (ii)

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.