結果

問題 No.2768 Password Crack
ユーザー naut3
提出日時 2024-06-01 02:20:52
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 190 ms / 2,000 ms
コード長 747 bytes
コンパイル時間 127 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 27,864 KB
平均クエリ数 984.27
最終ジャッジ日時 2024-12-21 04:34:14
合計ジャッジ時間 6,152 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 29
権限があれば一括ダウンロードができます

ソースコード

diff #

import random


def main():
    alphas = [chr(ord('a') + i) for i in range(26)]
    ans = []

    N = int(input())

    for i in range(N):
        random.shuffle(alphas)

        T = ['a' for _ in range(N)]
        counts_max = None
        max_char = None

        for x in alphas:
            T[i] = x

            print("? ", *T, sep="", flush=True)
            c = int(input())

            if counts_max is None:
                counts_max = c
                max_char = x
            else:
                if counts_max < c:
                    ans.append(x)
                    break
                elif counts_max > c:
                    ans.append(max_char)
                    break

    print("! ", *ans, sep='', flush=True)


main()
0