問題一覧 > 通常問題

No.2768 Password Crack

レベル : / AI推定難易度 : 800 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / リアクティブ問題 (詳しくはこちら)
タグ : (AC するまで非表示) / 解いたユーザー数 106
作問者 : srjywrdnprkt / テスター : 👑 p-adic
お気に入りにしたユーザー ProblemId : 10437 / 自分の提出
問題文最終更新日: 2024-05-30 17:43:50
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
yukicoder contest 431 (順位表) の他の問題:

Problem Statement

This is an interactive problem.

$S$ is a string of length $N$ consisting only of lowercase English letters. $S$ is not given directly.

Instead, you may ask the judge system the following question up to $2500$ times.

  • Choose a string $T$ of length $N$ consisting only of lowercase English letters, and ask for the number of positions at which $S$ and $T$ match. That is, ask for the number of integers $i$ satisfying $1\leq i \leq N$ such that the $i$-th character of $S$ and the $i$-th character of $T$ are equal.
  • Find the string $S$.

    Constraints

  • $N$ is an integer between $1$ and $100$, inclusive.
  • Input and Output

    This is an interactive problem (a problem in which the program you write and the judge program interact through input and output).

    First, the length $N$ of the string $S$ is given in the following format.
    $N$
    Repeat your questions until you can determine the string $S$.

    Print each question to standard output in the following format.
    $?$ $T$
    The response to it is given from standard input in the following format.
    $n$
    Here, $n$ is the number of positions at which $S$ and $T$ match.

    Once you have determined the string $S$, print it to standard output in the following format.
    $!$ $S$

    Notes

  • Each time you print output, end it with a newline and flush standard output. Otherwise, the judge result may be TLE or WA.
  • If you print invalid output, the judge result is undefined. Note that printing extra spaces or newlines also counts as invalid output.
  • Terminate your program immediately after answering with the string $S$. Otherwise, the judge result is undefined.
  • The query that gives your answer is not counted toward the number of questions.
  • Sample

    The following is an example of an interaction that starts with $S=$ pswd.

    Input Output Explanation
    4 The length of $S$, which is $4$, is given.
    ? abcd Ask for the number of positions at which $S$ and $T=$abcd match.
    1 $S$ and $T$ match at only $1$ position, the $4$-th character, so $1$ is returned.
    ? hoge Ask for the number of positions at which $S$ and $T=$hoge match.
    0 There are no positions at which $S$ and $T$ match, so $0$ is returned.
    ? pswd Ask for the number of positions at which $S$ and $T=$pswd match.
    4 $S$ and $T$ match at $4$ positions, the $1,2,3,4$-th characters, so $4$ is returned.
    ! pswd We now know that $S=$pswd, so print this.

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