Uva-10474-where is the Marble? (Base sort)

Source: Internet
Author: User

UVA-10474

Where is the Marble?
Time Limit: 3000MS Memory Limit: Unknown 64bit IO Format: %lld &%llu

Submit Status

Description

Raju and Meena love-to-play with marbles. They has got a lot of marbles with numbers written on them. At the beginning, Raju would place the marbles one after another in ascending order of the numbers written on them. Then Meena would ask Raju to find the first marble with a certain number. She would count 1...2...3. Raju gets one point to correct answer, and Meena gets the point if Raju fails. After some fixed number of trials the game ends and the player with maximum points wins. Today it ' s your chance to play as Raju. Being the Smart kid, you ' d be taking the favor of a computer. But don ' t underestimate Meena, she had written a program to keep track how much time you ' re taking to give all the answers . So now that you had to write a program, which would help you in your role as Raju.

Input

There can multiple test cases. Total no of test cases was less than 65. Each test case consists begins with 2 integers: N The number of marbles and Q the number of queries Mina would make. The next n lines would contain the numbers written on the n marbles. These marble numbers won't come in any particular order. Following Q lines would have Q queries. Be assured, none of the input numbers is greater than 10000 and none of them are negative.

Input is terminated by a test case where N = 0 and Q = 0.

Output

For each test case output, the serial number of the case.

For each of the queries, print one line of output. The format of this line would depend upon whether or not the query number was written upon any of the marbles. The different formats is described below:

    • 'x found at y', if the first marble with number x is found at position y. Positions is numbered 1, 2,..., N.
    • 'x not found', if the marble with number x was not present.

Look at the output for sample input for details.

Sample Input
4 1235155 213331230 0

Sample Output
case# 1:5 found at 4case# 2:2 not Found3 found at 3


Problem-setter:monirul Hasan Tomal, southeast University

Source

Root:: Prominent problemsetters:: Monirul Hasan
Root:: AOAPC i:beginning algorithm Contests (Rujia Liu):: Volume 1. Elementary Problem Solving:: sorting/searching
Root:: Competitive programming:increasing The Lower Bound of programming contests (Steven & Felix Halim):: Chapter 3. Problem solving Paradigms:: Divide and conquer
Root:: Competitive programming 2:this increases the lower bound of programming contests. Again (Steven & Felix Halim):: Problem Solving Paradigms:: Divide and Conquer-binary Search
Root:: AOAPC i:beginning algorithm Contests (Rujia Liu):: Volume 3. Brute Force:: Backtracking-easy
Root:: Competitive programming 3:the New Lower Bound of programming contests (Steven & Felix Halim):: Problem Solvi Ng Paradigms:: Divide and Conquer:: Binary Search
Root:: AOAPC ii:beginning algorithm Contests (Second Edition) (Rujia Liu):: Chapter 5. C + + and STL:: Examples

Submit Status







Idea: is to give a set of data, this group of data in order from small to large, and then query whether a number in the array, the output row in the first


AC Code:













Uva-10474-where is the Marble? (Base sort)

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.