Guess the line
Limits: 2 sec., 512 MiB
This statement was translated automatically from Ukrainian.
This is an interactive problem (where your program interacts with the jury’s program through input and output).
Zenyk and Marichka have a farm with \(n\) stallions. The horses on the farm have different coats — black, bay, buckskin, and others. There are a total of \(26\) different coats, denoted by lowercase Latin letters.
The farmers lined up their stallions in a line. The line can be represented as a string \(s\) of \(n\) lowercase English alphabet letters, denoting the coats of the horses in the line.
Once the horses are lined up, Zenyk and Marichka will no longer change their order in the line. That is, the string \(s\) is fixed in advance.
However, the farmers do not tell you the string \(s\) — you must guess it within a limited number of attempts.
In each attempt, you tell the farmers a string \(t\) of lowercase English alphabet letters, and they give you one of three responses:
the string \(t\) matches the string \(s\),
the string \(t\) is lexicographically smaller than the string \(s\),
the string \(t\) is lexicographically larger than the string \(s\).
A string \(a\) is lexicographically smaller than a string \(b\) if \(a\) appears in the dictionary before \(b\).
Guess the line of stallions in no more than \(1000\) attempts. The total length of the strings \(t\) in your attempts must not exceed \(4 \cdot 10^5\).
Input
You are given an integer \(n\) — the number of horses in the line.
After reading the number \(n\), the interaction between your program and Zenyk and Marichka begins, during which your program makes attempts to guess the line, and Zenyk and Marichka respond to them.
To make an attempt, output \(t\) — a string of lowercase English alphabet letters.
In response to the attempt, Zenyk and Marichka will give one of three characters on a separate line:
character
=, if the string \(t\) matches the string \(s\),character
<, if the string \(t\) is lexicographically smaller than the string \(s\),character
>, if the string \(t\) is lexicographically larger than the string \(s\).
If you receive =, in response to your attempt, it means
you have guessed the string \(s\).
After that, immediately terminate your program. Otherwise, your answer
will not be counted.
If the attempt is invalid (for example, the maximum number of queries
is exceeded), Zenyk and Marichka will give you -1 in
response and terminate the interaction. In this case, terminate the
program to receive the Wrong Answer verdict. If you do not
do this, you may receive the Run-Time Error verdict.
Make sure to flush the output after printing each line. To do this, you can use:
fflush(stdout),cout << endlorcout.flush()inC++;System.out.flush()inJava;flush(output)inPascal;sys.stdout.flush()inPython;Console.Out.Flush()inC#.
Constraints
\(1 \le n \le 210\),
you are allowed to make no more than \(1000\) attempts,
the total length of the strings \(t\) in your attempts must not exceed \(4 \cdot 10^5\).
Scoring consists of the following subtasks:
1 point for the example from the statement,
14 points: \(n = 1\),
19 points: \(n \le 2\),
24 points: \(n \le 20\),
38 points: \(n \le 200\),
4 points: no additional constraints.
You will receive points for a subtask only if your program passes all tests in that subtask.
Notes
Below is an example of interaction for \(n=10\), \(s
=\)algotester.
| Input | Output | Description |
|---|---|---|
10 |
Zenyk and Marichka state the number \(n\). | |
olympiad |
The participant makes the attempt
olympiad. |
|
> |
They respond that the string
olympiad is lexicographically larger than \(s\). |
|
algo |
The participant makes the attempt
algo. |
|
< |
They respond that the string
algo is lexicographically smaller than \(s\). |
|
algorithm |
The participant makes the attempt
algorithm. |
|
< |
They respond that the string
algorithm is lexicographically smaller than \(s\). |
|
algotester |
The participant makes the attempt
algotester. |
|
= |
They respond that the string
algotester is equal to \(s\). |
Submit a solution
| Element Type | Created | Who | Problem | Compiler | Result | Time (sec.) | Memory (MiB) | # | Actions |
|---|
| Element Type | Created | Who | Problem | Compiler | Result | Time (sec.) | Memory (MiB) | # | Actions |
|---|