Contest Day 2 - JOI Open Contest
Anna invented a secret binary operation
Anna planned to play a game with Bruno. She asked him to guess the operation
Bruno said it is difficult to play this game without hints. Anna decided to give hints to him. Each hint is given as follows: he will choose
Task
Write a program which implements Bruno's strategy to ask for hints and answer Anna's queries correctly.
Implementation Details
You should write a program which implements the strategy to ask for hints and answer Anna's queries. Your program should include the header file secret.h
by #include "secret.h"
Your program should implement the following procedures.
- Copy
void Init(int N, int A[])
This procedure is called only once in the beginning. The parameter
is the number of the integers shown by Anna. The parameter is an array of length . The elements are the integers shown by her. - Copy
int Query(int L, int R)
This procedure is called when Anna gives a query to Bruno. This means she is asking the value of
.
The following procedure can be called by your program.
- This procedure is called when Bruno asks for a hint. This means he is asking about the value ofCopy
int Secret(int X, int Y)
. The parameters and should be integers satisfying and . If this procedure is called with parameters not satisfying this condition, your program is considered as Wrong Answer [1] and terminated.
This procedure returns the value of .
Constraints
All input data satisfy the following conditions.
. .- The number of calls to
Query
is less than or equal to .
Grading
The score will be given to your program if your program terminates successfully for each test case, it is not considered as Wrong Answer [1], and it returns the correct value for each call to Query
.
Your score is calculated as follows.
- Your score is
if the following two conditions are satisfied for each test case:- In
Init
, the number of calls toSecret
is less than or equal to . - In each call to
Query
, the number of calls toSecret
is less than or equal to .
- In
- Your score is
if your program does not satisfy (1), and the following two conditions are satisfied:- In
Init
, the number of calls toSecret
is less than or equal to . - In each call to
Query
, the number of calls toSecret
is less than or equal to .
- In
- Your score is
if your program does not satisfy (1) or (2).
Comments