問題一覧 > 通常問題

No.2925 2-Letter Shiritori

レベル : / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / リアクティブ問題 (詳しくはこちら)
タグ : (解説公開後に AC するまで非表示) / 解いたユーザー数 147
作問者 : 👑 loop0919 / テスター : ice_ut hirayuu_yc kusirakusira mymelochan tnodino nouka28 uruzunyaa
お気に入りにしたユーザー ProblemId : 11036 / 自分の提出
問題文最終更新日: 2024-10-12 07:22:38
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
第3回緑以下コンテスト (順位表) の他の問題:

Problem Statement

This is an interactive problem (a problem in which your program and the judge system communicate through input and output).
You are given a lowercase English letter $\alpha$. You play the following game against the judge system.

There is a blackboard on which strings can be written; initially, nothing is written on it.
Starting with the first player, the players alternately repeat the following operation. Here, let $S_i$ be the $i$-th string written on the blackboard.

  • Write on the blackboard a string satisfying the following conditions. (Suppose that immediately before this operation, $n$ strings $(n \ge 0)$ $(S_1, S_2, \cdots, S_n)$ are written on the blackboard.)
    • It consists only of lowercase English letters and has a length of exactly $2$.
    • It is not equal to any of the strings currently written on the blackboard.
    • The $1$st character of the string is
      • $\alpha$ if $n = 0$.
      • the $2$nd character of $S_n$ if $n \geq 1$.

The player who first becomes unable to perform the operation loses, and the other player wins.

You play this game as the first player. Play the game against the judge system and win in the minimum number of moves.
It can be proved that the first player has a winning strategy under optimal play.

Constraints

  • $\alpha$ is a lowercase English letter.
  • The string $T$ output by the system satisfies the conditions in the problem statement.

Input and Output

This is an interactive problem (a problem in which your program and the judge system communicate through input and output).

First, a lowercase English letter $\alpha$ is given from the input in the following format. Receive it.

$\alpha$

Then, the game starts immediately, with you as the first player and the judge system as the second player.
Let $m$ be the minimum number of operations required to win this game.
Interact with the judge system until the game ends, and win the game in at most $m$ operations.


When your turn comes, output the string $S$ to write on the blackboard in the following format.

? $S$

On the judge system's turn, one of the following strings is output.

  • In any of the following cases, the judge system outputs in the format below.
    • You made an output that violates the output format or the conditions.
    • You have not yet won even after writing on the blackboard $m$ times.
    ! LOSE
    
    In this case, your answer is confirmed to be incorrect. Terminate immediately.

  • If ! LOSE has not yet been output and there is no string the judge system can write on the blackboard, the judge system outputs in the following format.
    ! WIN
    
    In this case, you have won in the minimum number of moves. Your submission will be judged as AC if you terminate your program immediately.

  • If there is a string that can be written on the blackboard, the judge system outputs the string $T$ to write on the blackboard in the following format.
  • ? $T$
    

If the judge returns ! WIN or ! LOSE, the game has already ended. In this case, terminate your program immediately.

Notes

  • Each time you produce output, append a newline at the end and flush standard output. Otherwise, the judge result may be TLE.
  • If you produce invalid output during the interaction, or if your program terminates midway, the judge result is undefined.
    In particular, note that if a runtime error occurs during the execution of your program, the judge result may be WA or TLE instead of RE.
  • Terminate your program immediately once the game ends. Otherwise, the judge result is undefined.

Sample

This is an example of input and output for the case $\alpha = $ a.
Note that this sample is an example of input and output that results in WA.
InputOutputExplanation
aThe lowercase English letter $\alpha = $ a is given as input.
? ac You write ac on the blackboard. The blackboard now contains $($ ac $)$.
? cd The judge system writes cd on the blackboard. The blackboard now contains $($ ac$, $ cd $)$.
? db You write db on the blackboard. The blackboard now contains $($ ac $, $ cd $, $ db $)$.
? bb The judge system writes bb on the blackboard. The blackboard now contains $($ ac $, $ cd $, $ db $, $ bb $)$.
? bb You try to write bb on the blackboard, but bb is already written on the blackboard.
! LOSEYou lost because your output violated the conditions. The judge result is WA.

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。