10451 - EEDS 樂透對獎程式   

Description

We want to write a program to check whether we win the lottery or not.

Input

The first input character indicates the algorithm we want the program to use (students are required to implement three algorithms in a program).
I: iterative
R: recursive
S: STL

A number following the character declares the total number of sets of winning numbers. 
For example, in the sample input, there are three sets of winning numbers. 
This number can be 1 to 999.

Corresponding unsorted winning numbers follow the number.

A number following the winning numbers declares the total number of lotteries we bought. 
For example, In the sample input, there are two sets of our bought lotteries. 
This number is equal to or greater than 1.

Corresponding unsorted lotteries follow the number.

The 28th test case is just the same as the following sample input.

Output

Most of the information from input are repeated, except ...

Winning numbers are sorted, both internal to each set and among the sets.

Our bought lotteries are sorted, only internal to each set. 
We don't need to perform among-set sorting for our lotteris.

Whether we win the lottery (six numbers are the same to a set of winning numbers) is shown.
Y means yes, and N means no. 

Furthermore, please also show which set of winning numbers (after sorting) is matched.  (1-based instead of 0-based)

The 28th test case expects just the same as the following sample output.

Be careful not to print out unnecessary space and newline characters.
Especially, the last output line should not contain a newline character.
 

A C++ program that can pass the 28th test case is as follows.

#include
using namespace std;
int main()
{
    char c;
    while(cin >> c);  // read all input

    // expected output for the 28th test case
    cout << "R" << endl
         << "3" << endl
         << "01 04 14 25 29 39" << endl
         << "02 10 26 29 40 45" << endl
         << "11 16 17 25 33 41" << endl
         << "2" << endl
         << "02 10 26 29 40 45 Y 2" << endl
         << "01 06 15 17 23 24 N";
    return 0;
}

 

Sample Input  Download

Sample Output  Download

Tags




Discuss