atcoder#AGC044D. [AGC044D] Guess the Password

[AGC044D] Guess the Password

Score : 11001100 points

Problem Statement

This is an interactive task.

You have to guess a secret password SS. A password is a nonempty string whose length is at most LL. The characters of a password can be lowercase and uppercase english letters (a, b, ... , z, A, B, ... , Z) and digits (0, 1, ... , 9).

In order to guess the secret password SS you can ask queries. A query is made of a valid password TT, the answer to such query is the edit distance between SS and TT (the operations considered for the edit distance are: removal, insertion, substitution). You can ask at most QQ queries.

Note: For a definition of edit distance (with operations: removal, insertion, substitution), see this wikipedia page

.

Constraints

  • L=128L = 128
  • Q=850Q = 850
  • The secret password SS is chosen before the beginning of the interaction.

Interaction

To ask a query, print on Standard Output (with a newline at the end)

? T

The string TT must be a valid password.

The answer ansans to each query shall be read from Standard Input in the form:

ans

As soon as you have determined the hidden password SS, you should print on Standard Output (with a newline at the end)

! S

and terminate your program.

Judgement

  • After each output, you must flush Standard Output. Otherwise you may get TLE.
  • After you print (your guess of) the hidden password, the program must be terminated immediately. Otherwise, the behavior of the judge is undefined.
  • If the password you have determined is wrong, you will get WA.
  • If you ask a malformed query (for example because the string is not a valid password, or you forget to put ?) or if your program crashes or if you ask more than QQ queries, the behavior of the judge is undefined (it does not necessarily give WA).

Samples

In the only sample testcase of this problem the hidden password is Atcod3rIsGreat.

The following one is an example of interaction if S=S=Atcod3rIsGreat.

Input Output
? AtcoderIsBad\texttt{? AtcoderIsBad}
55
? AtcoderIsGreat\texttt{? AtcoderIsGreat}
11
! Atcod3rIsGreat\texttt{! Atcod3rIsGreat}