| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 6 초 | 2048 MB | 23 | 3 | 3 | 30.000% |
Anna and Bruno like fortune-telling and enjoy playing various styles of fortune-telling together. Today, they will play fortune-telling using cards, which is described below. They will play it for $Q$ times.
The fortune-telling is considered more proficient when fewer cards are on the table. Write a program to implement Anna’s and Bruno’s strategies to succeed in all $Q$ fortune tellings. In this task, the fewer cards Anna puts on the table, the higher the score will be.
The first file is Anna.cpp. This file is intended to implement Anna’s strategy and should implement the following function. The program should include Anna.h using the preprocessor directive #include.
void Anna(int N)
This function is called $Q$ times. The $i$-th call ($1 ≤ i ≤ Q$) of this function corresponds to Anna’s procedure in the $i$-th fortune-telling.
N is the number of cards that Anna draws.For each call of the function Anna, this function must call the following function $N + 1$ times.
int DrawCard(int x)
Using this function, Anna draws the card from the deck, and selects whether to discard it or put it on the table. She obtains the number written on the $j$-th card via the return value of the $j$-th call ($1 ≤ j ≤ N$) of this function. She designates the operation for the $(k - 1)$-th card via the parameter for the $k$-th call ($2 ≤ k ≤ N + 1$) of this function.
The second file is Bruno.cpp. This file is intended to implement Bruno’s strategy and should implement the following function. The program should include Bruno.h using the preprocessor directive #include.
int Bruno(int N, int L, std::vector<int> C)
This function is called exactly once after each call of the function Anna, totaling $Q$ times. The $i$-th call ($1 ≤ i ≤ Q$) of this function corresponds to Bruno’s procedure in the $i$-th fortune-telling. It must return the number of cards with $1$ among the cards Anna drew.
N is the number of cards that Anna drew.L is the number of cards on the table.C is the array of length $L$, where C[l-1] is the number written on the $l$-th leftmost card ($1 ≤ l ≤ L$) on the table.Bruno is not equal to the number of cards with $1$ among the cards Anna drew, your program will be judged as Wrong Answer [4].Important Notices
You can download an archive file from the contest webpage which contains the sample grader to test your program. The archive file also contains a sample source file of your program.
The sample grader is the file grader.cpp. In order to test your program, put grader.cpp, Anna.cpp, Bruno.cpp, Anna.h, Bruno.h in the same directory, and run the following command to compile your programs.
g++ -std=gnu++20 -O2 -o grader grader.cpp Anna.cpp Bruno.cpp
Instead, you may run compile.sh contained in the archive file.
./compile.sh
When the compilation succeeds, the executable file grader is generated.
Note that the actual grader is different from the sample grader. The sample grader will be executed as a single process, which will read input data from the standard input and write the results to the standard output and the standard error output.
Input for the Sample Grader
The sample grader reads the following data from the standard input.
$Q$ $N$
$A_{1,1}$ $A_{1,2}$ $\cdots$ $A_{1,N}$
$A_{2,1}$ $A_{2,2}$ $\cdots$ $A_{2,N}$
$\vdots$
$A_{Q,1}$ $A_{Q,2}$ $\cdots$ $A_{Q,N}$
$A_{i, j}$ ($1 ≤ i ≤ Q$, $1 ≤ j ≤ N$) is the number written on the $j$-th card Anna draws in the $i$-th fortune telling.
Output of the Sample Grader
The sample grader outputs the following information to the standard output and the standard error output (quotes for clarity).
Accepted: 100”.Wrong Answer [1]”.If your program meets the conditions of several types of wrong answer, the sample grader reports only one of them. The sample grader may terminate the execution when one of the conditions for wrong answer is met.
All the input data satisfy the following conditions.
The actual grader is not adaptive for all testcases. It means that the sequence of numbers written on the cards is fixed before the program’s execution.
If your program is judged as any type of Wrong Answer [1] – [4] (see Implementation Details), Time Limit Exceeded, Memory Limit Exceeded, or Runtime Error, in any testcase, your score is $0$ points.
If your program is judged as correct for all testcases, your score is determined by the maximum number of calls for the function DrawCard with parameter $0 ≤ x$, among all plays of the fortune-telling for all testcases. Let $L$ be this number. Your score will be:
Here is a sample input for the sample grader and corresponding function calls.
| Sample Input 1 | Sample Function Calls | |||
|---|---|---|---|---|
| Call | Return Value | Call | Return Value | |
2 5 0 1 0 0 1 1 1 0 1 0 |
Anna(5) |
|||
DrawCard(-1) |
0 |
|||
DrawCard(0) |
1 |
|||
DrawCard(-1) |
0 |
|||
DrawCard(1) |
0 |
|||
DrawCard(-1) |
1 |
|||
DrawCard(1) |
-1 |
|||
Bruno(5, 3, [0, 1, 0]) |
2 |
|||
Anna(5) |
||||
DrawCard(-1) |
1 |
|||
DrawCard(0) |
1 |
|||
DrawCard(1) |
0 |
|||
DrawCard(2) |
1 |
|||
DrawCard(-1) |
0 |
|||
DrawCard(1) |
-1 |
|||
Bruno(5, 4, [1, 0, 1, 0]) |
3 |
|||
The sample input consists of $Q$ ($= 2$) plays of fortune-telling, and the number of cards Anna draws from the deck is $N$ ($= 5$). In this example, in the first fortune-telling, Anna plays in the following procedure:
Then, Bruno sees the sequence of cards: $0$, $1$, $0$. Based on this information, Bruno guesses that the number of cards with $1$ among the cards Anna drew is $2$. Since this is correct, fortune-telling is a success. The number of cards Anna put on the table is $L = 3$.
In the second fortune-telling, the number of cards Anna put on the table is $L = 4$.
Note that this sample input does not satisfy the constraints of the problem. The file sample-01-in.txt, which can be downloaded from the contest site, corresponds to Sample Input 1. The file sample-02-in.txt, which can be downloaded from the contest site, is a sample input that satisfies the constraints.
C++17, C++20, C++23, C++26, C++17 (Clang), C++20 (Clang)