| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 2 초 | 1024 MB | 24 | 8 | 7 | 58.333% |
Bitaro and Bibako are archaeologists who excavated and investigated the ruin of JOI Kingdom. In the ruin, Bitaro found an old stone slate, and Bibako found an old machine.
From the results of the study, Bitaro found out that a string $S$ of length $N$ was written on the stone slate. Each character of the string is either ‘0’ or ‘1’. However, he does not yet know each character of the string $S$.
On the other hand, from the results of the study, Bibako found out how to use the machine. To use it, we put the stone slate on the machine, input an integer $m$ and two sequences of integers $a,ドル $b,ドル and make a query. Here the integer $m$ and the sequences of integers $a,ドル $b$ should satisfy the following conditions:
If we put the stone slate on the machine, input an integer $m$ and two sequences of integers $a,ドル $b,ドル and make a query, the machine will operate as follows and will show an integer.
0’, the machine sets $a_x$ in the memory area of the machine. Here, $a_x$ is the $x$-th element of the sequence $a,ドル if we count the elements of the sequence $a$ so that the first element is the 0ドル$-th element.1’, the machine sets $b_x$ in the memory area of the machine. Here, $b_x$ is the $x$-th element of the sequence $b,ドル if we count the elements of the sequence $b$ so that the first element is the 0ドル$-th element.Using the machine, Bitaro wants to specify the string written on the stone slate. However, since the machine is very fragile, the number of queries cannot exceed 1ドル,000円$. Moreover, the maximum of the integer $m$ input to the machine for a query should be as small as possible.
Write a program which, using the machine, specifies the string written on the stone slate.
You need to submit one file.
The file is ancient2.cpp. It should implement the following function. The program should include ancient2.h using the preprocessing directive #include.
std::string Solve(int N)
This function is called only once for each test case. This function should return a string which is the same as the string $S$ written on the stone slate.
N is the length $N$ of the string $S$ written on the stone slate.0’ or ‘1’. If this condition is not satisfied, your program is judged as Wrong Answer [2].Your program can call the following function.
int Query(int m, std::vector<int> a, std::vector<int> b)
Using this function, your program can make a query.
m is the integer $m$ input to the machine.a, b are the two sequences of integers $a,ドル $b$ input to the machine.m should be between 1ドル$ and 1ドル,002円,ドル inclusive. If this condition is not satisfied, your program is judged as Wrong Answer [4].a, b are equal to $m$. If this condition is not satisfied, your program is judged as Wrong Answer [5].a, b is between 0ドル$ and $m - 1,ドル inclusive. If this condition is not satisfied, your program is judged as Wrong Answer [6].Query should not be called more than 1ドル,000円$ times. If it is called more than 1ドル,000円$ times, your program is judged as Wrong Answer [7].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, ancient2.cpp, ancient2.h in the same directory, and run the following command to compile your programs. Instead, you may run compile.sh contained in the archive file.
g++ -std=gnu++17 -O2 -o grader grader.cpp ancient2.cpp
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.
Input for the Sample Grader
The sample grader reads the following data from the standard input.
$N$
$S$
Output of the Sample Grader
The sample grader outputs the following information to the standard output (quotes for clarity).
m of the function Query as “Accepted: 22”. However, if your program is judged as correct without calling the function Query, it outputs “Accepted: 0”.Wrong Answer [4]”.If your program satisfies the conditions of several types of Wrong Answer, the sample grader reports only one of them.
0’ or ‘1’.For every test case, the actual grader is not adaptive. This means the grader has a fixed answer in the beginning.
If your program is judged as Wrong Answer for any of the test cases, your score for this task is 0ドル$.
If your program is judged as correct for all the test cases, your score is calculated by $M,ドル which is the maximum of the parameter m of the function Query for all the test cases. However, if your program is judged as correct without calling the function Query, your score is calculated by $M = 0$.
Here $\lfloor x \rfloor$ is the largest integer not exceeding $x$.
Here is a sample input for the sample grader and corresponding function calls.
Solve
Return Values
Function Call to Query
Return Values
3 110
Solve(3)
Query(4, [3, 3, 2, 2], [2, 2, 1, 0])
3
Query(2, [0, 1], [1, 0])
0
Query(1, [0], [0])
0
Query(3, [1, 1, 1], [1, 1, 1])
1
"110"
Assume that the string $S$ written on the stone slate is “110”. If we put the stone slate on the machine, input $(m, a, b) = (4, [3, 3, 2, 2], [2, 2, 1, 0]),ドル and make a query, the machine will operate as follows.
1’, the machine sets $b_0,ドル i.e. 2ドル,ドル in the memory area of the machine.1’, the machine sets $b_2,ドル i.e. 1ドル,ドル in the memory area of the machine.0’, the machine sets $a_1,ドル i.e. 3ドル,ドル in the memory area of the machine.Note that this sample input does not satisfy the constraint $N = 1,000円$.
Among the files which can be obtained from the contest webpage, sample-02.txt satisfies the constraint.
C++17, C++20, C++17 (Clang), C++20 (Clang)