ENIGMA-0x03 (2025) - A1 Malicious Frogs
View as PDFMalicious Frogs

In the lake there are lily pads arranged in a row.
Each one has a different name, a natural number from
to
.
You know the order of the lily pads, but during the night some frogs perform the following procedure to confuse you.
They choose a divisor of , say
, with
.
Then,
times they select
lily pads that have not been selected before and place them in a circle, such that if you start from the lily pad that was earlier in the original sequence and continue clockwise, you obtain the previous relative order of the lily pads.
Then they start from the nd lily pad of the circle and, moving clockwise, they place them back into the row, each time filling the first empty position.
The next morning your colleague sees this and wants to give you a puzzle so that you can determine .
You are allowed to ask him only
questions of the following type:
"What is the name of the lily pad that is the
-th in the sequence?"
Input (STDIN) - Output (STDOUT)
This problem is interactive, which means that you give instructions to the judge and it responds with information so you can continue.
- The first line contains an integer
: the number of lily pads. (
)
- The second line contains
integers: the names of the lily pads in the initial order.
- You can make
types of queries:
1 Κ- you ask which lily pad is at positionin the new sequence, and you receive the answer.
2 Μ- you guess the number, the group size.
You are allowed to make type
queries and only one query of type
.
Once you make it, the program terminates.
Example
Input (STDIN)
9
6 3 90 45 67 87 777 4 21
Possible questions and answers could be the following:
Program Output (STDOUT) |
Judge Output (STDIN) |
|---|---|
1 1 | |
4 |
|
1 9 | |
6 |
|
1 4 | |
67 |
|
1 7 | |
90 |
|
2 3 | |
ΟΚ |
A possible grouping and rearrangement of the lily pads could be the following:
group:
group:
group:
Final order:
4 45 87 67 3 777 90 21 6
Subtasks
For % of the cases, the names of the lily pads are equal to their position in the initial sequence.
Note: In order for the interactive grader to work correctly, you must flush the lines that you print.
This can be done as follows:
- Python:
print()does it automatically
print("1 8")
- C/C++ (
cstdio): useprintfas normalprintf("1 8\n"); - C++ (
iostream): useendlcout << "1 8" << endl;
Comments