結果

問題 No.2768 Password Crack
ユーザー tkykwtnbtkykwtnb
提出日時 2024-05-31 23:03:04
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 213 ms / 2,000 ms
コード長 806 bytes
コンパイル時間 338 ms
コンパイル使用メモリ 82,416 KB
実行使用メモリ 93,492 KB
平均クエリ数 881.63
最終ジャッジ日時 2024-05-31 23:03:11
合計ジャッジ時間 6,399 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 66 ms
69,380 KB
testcase_01 AC 62 ms
70,404 KB
testcase_02 AC 213 ms
92,556 KB
testcase_03 AC 62 ms
70,168 KB
testcase_04 AC 169 ms
92,788 KB
testcase_05 AC 78 ms
76,200 KB
testcase_06 AC 168 ms
93,248 KB
testcase_07 AC 77 ms
78,264 KB
testcase_08 AC 90 ms
80,164 KB
testcase_09 AC 167 ms
92,872 KB
testcase_10 AC 175 ms
93,080 KB
testcase_11 AC 173 ms
93,136 KB
testcase_12 AC 172 ms
93,240 KB
testcase_13 AC 176 ms
93,052 KB
testcase_14 AC 168 ms
93,228 KB
testcase_15 AC 147 ms
92,344 KB
testcase_16 AC 169 ms
93,276 KB
testcase_17 AC 169 ms
93,084 KB
testcase_18 AC 169 ms
93,488 KB
testcase_19 AC 109 ms
82,684 KB
testcase_20 AC 104 ms
81,724 KB
testcase_21 AC 165 ms
93,332 KB
testcase_22 AC 137 ms
91,088 KB
testcase_23 AC 82 ms
78,320 KB
testcase_24 AC 103 ms
82,188 KB
testcase_25 AC 168 ms
93,492 KB
testcase_26 AC 103 ms
81,664 KB
testcase_27 AC 138 ms
90,972 KB
testcase_28 AC 88 ms
79,268 KB
testcase_29 AC 91 ms
79,004 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def get_password(ans):
    ret=[]
    for c in ans:
        ret.append(chr(c+ord("a")))
    return "".join(ret)
N=int(input())
ans=[0 for _ in range(N)]
i=0
phrase=get_password(ans)
print(f"? {phrase}")
match=int(input())
if match==N:
    exit(print(f"! {phrase}"))
while 1:
    # matchが減るなら一つ前が正解。変わらないなら繰り返す。増えたらそれが正解。
    while ans[i]<25:
        pre=match
        ans[i]+=1
        phrase=get_password(ans)
        if ans[i]==25:
            match+=1
            break
        print(f"? {phrase}")
        match=int(input())
        if match>pre:break
        elif match<pre:
            ans[i]-=1
            phrase=get_password(ans)
            match+=1
            break
    if match==N:
        exit(print(f"! {phrase}"))
    i+=1
0