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 of length 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 .
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 and two sequences of integers , , and make a query. Here the integer and the sequences of integers , should satisfy the following conditions:
- The integer is between and , inclusive.
- Both of the lengths of the sequences , are equal to .
- Every element of the sequences , is an integer between and , inclusive.
If we put the stone slate on the machine, input an integer m and two sequences of integers , , and make a query, the machine will operate as follows and will show an integer.
- The machine sets in the memory area of the machine.
- The machine performs the following operations. The -th () operation proceeds as
follows.
Let be the current integer set in the memory area of the machine. The machine reads the character . Here, is the -th character of the string , if we count the characters of the string so that the first character is the 0-th character.- If is
0
, the machine sets in the memory area of the machine. Here, is the -th element of the sequence , if we count the elements of the sequence so that the first element is the -th element. - If is
1
, the machine sets in the memory area of the machine. Here, is the -th element of the sequence , if we count the elements of the sequence so that the first element is the -th element.
- If is
- The machine shows the integer which is finally set in the memory area.
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 . Moreover, the maximum of the integer 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
Implementation Details
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 written on the stone slate.- The parameter
N
is the length of the string written on the stone slate. - This function should return a string of length . If the length is different from , your program is judged as
Wrong Answer [1]
. - Each character of the return value is either
0
or1
. If this condition is not satisfied, your program is judged asWrong Answer [2]
. - The return value should be the same as the string written on the stone slate. If this condition is not satisfied, your program is judged as
Wrong Answer [3]
.
- The parameter
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.- The parameter
m
is the integer input to the machine. - The parameters
a
,b
are the two sequences of integers , input to the machine. - The return value is the integer shown by the machine when we put the stone slate on the machine, input the above integer and sequences, and make a query.
- The parameter
m
should be between and , inclusive. If this condition is not satisfied, your program is judged asWrong Answer [4]
. - Both of the lengths of the parameters
a
,b
are equal to . If this condition is not satisfied, your program is judged asWrong Answer [5]
. - Every element of the parameters
a
,b
is between and , inclusive. If this condition is not satisfied, your program is judged asWrong Answer [6]
. - The function
Query
should not be called more than times. If it is called more than times, your program is judged asWrong Answer [7]
.
- The parameter
Important Notices
- Your program can implement other functions for internal use, or use global variables.
- Your program must not use the standard input and the standard output. Your program must not communicate with other files by any methods. However, your program may output debugging information to the standard error.
Compilation and Test Run
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.
Output of the Sample Grader
The sample grader outputs the following information to the standard output.
- If your program is judged as correct, it reports the maximum of the parameter m of the function Query
as
Accepted: 22
. However, if your program is judged as correct without calling the function Query, it outputsAccepted: 0
. - If your program is judged as any type of Wrong Answer, the sample grader writes its type as
Wrong Answer [4]
. If your program satisfies the conditions of several types of Wrong Answer, the sample grader reports only one of them.
Constraints
All the input data satisfy the following conditions.
- .
- is a string of length .
- Each character of the string is either
0
or1
.
Notices for Grading
For every test case, the actual grader is not adaptive. This means the grader has a fixed answer in the beginning.
Grading
If your program is judged as Wrong Answer for any of the test cases, your score for this task is .
If your program is judged as correct for all the test cases, your score is calculated by , which is the maximum of the parameter 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 .
- If , your score is points.
- If , your score is points.
Here is the largest integer not exceeding .
Sample Communication
Here is a sample input for the sample grader and corresponding function calls.
Sample Input 1 | Sample Function Calls | |||
---|---|---|---|---|
Function Call to Solve |
Return Values | Function Call to Query |
Return Values | |
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
, and make a query, the machine will operate as follows.
- The machine sets 0 in the memory area of the machine.
- For the first operation, since is
1
, the machine sets , i.e. , in the memory area of the machine. - For the second operation, since is
1
, the machine sets , i.e. , in the memory area of the machine. - For the third operation, since is
0
, the machine sets , i.e. , in the memory area of the machine. - Since the integer which is finally set in the memory area is , the machine shows .
Note that this sample input does not satisfy the constraint . Among the files which can be obtained from the contest webpage, sample-02.txt
satisfies the constraint.
Comments