After one year of playing hide-and-seek, Lulu and Tanaka have finally found each other. Now, it is time for them to go back to solving impossible programming tasks.
Today, Lulu came to Tanaka with yet another interesting algorithmic game, which is played in two different rounds:
Round 1: Given two numbers and , Tanaka must choose a set of intervals . For each such interval, must hold. The size of the set must be at most .
Round 2: Lulu gives Tanaka, one by one, several queries in the form of intervals with . For each query, Tanaka must choose a subset of the intervals in Round 1, so that for all integer values val contained by , there exists at least one interval in the subset which contains , and for all integer values which are not contained by , there are no intervals in the subset which contain . Moreover, it must hold that for each query. (We say an integer value is contained by an interval if and only if ).
Since Lulu likes disjoint intervals, he will give Tanaka of the score for the game only if for each query, all intervals chosen by Tanaka are disjoint. However, if all the answers to the queries are right, but the intervals are not disjoint, Tanaka will still get of the score.
Lulu also wants the set chosen in round 1 to be relatively small. After hearing about this task, Tanaka said to Lulu: "Answering your queries won't be hard, Lulu!" However, he needs your help. Your task is to write a program which can choose the initial set and then answer to all Lulu’s queries.
Interaction protocol
The contestant must implement two functions:
void init(int N, int K);
void query(int a, int b);
The contestant may call the following function:
void chooseInterval(int left, int right);
The function init
will be called exactly once, at the beginning of the interaction. The function will be supplied with the values and , the two numbers which were given to Tanaka in round 1. The contestant must call the function chooseInterval
not more than times with the intervals which Tanaka initially chose in round 1. Then, the committee will call the function query
multiple times. It will be supplied with the values and , representing a query. The contestant must call again the function chooseInterval
for the intervals chosen by Tanaka from the list he provided in round 1.
Attention! The contestant must not implement the main
function, and must #include
the game.h
header! Contestants are allowed to use global variables and other functions, which will be kept between interactions.
Scoring
Let be the amount of intervals chosen by the contestant's program and the maximal amount of intervals which can be chosen for each subtask. Let be the maximal score for a subtask. Let if the intervals chosen by Tanaka in each query are disjoint, and otherwise. If then the score for the test will be . Otherwise, the score for each test in the subtask will be equal to:
The score for a subtask will be the minimum score among all its tests.
Restrictions
- Let be the numbers of times the
query
function will be called by the committee.
Subtask 1 (6 points)
- , , ,
Subtask 2 (6 points)
- , , ,
Subtask 3 (9 points)
- , , ,
Subtask 4 (9 points)
- , , ,
Subtask 5 (11 points)
- , , ,
Subtask 6 (8 points)
- , , ,
Subtask 7 (7 points)
- , , ,
Subtask 8 (6 points)
- , , ,
Subtask 9 (6 points)
- , , ,
Subtask 10 (6 points)
- , , ,
Subtask 11 (7 points)
- , , ,
Subtask 12 (9 points)
- , , ,
Subtask 13 (10 points)
- , , ,
Examples
- Input:
init(5,3)
- Output:
chooseInterval(1,1) chooseInterval(2,3) chooseInterval(4,4) chooseInterval(4,5)
- Input:
query(1,3)
- Output:
chooseInterval(1,1) chooseInterval(2,3)
- Input:
query(2,4)
- Output:
chooseInterval(2,3) chooseInterval(4,4)
- Input:
query(1,5)
- Output:
chooseInterval(1,1) chooseInterval(2,3) chooseInterval(4,5)
Explanations
The function init
is called by the committee, with values and . The chosen intervals are: .
For the first query, and . The chosen intervals are: . The number is contained by , is contained by and is contained by .
For the second query, and . The chosen intervals are: . The number is contained by , is contained by and is contained by .
For the third query, and . The chosen intervals are: . The number is contained by , is contained by , is contained by , is contained by and is contained by .