結果
| 問題 | 
                            No.2768 Password Crack
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2024-05-31 22:59:05 | 
| 言語 | PyPy3  (7.3.15)  | 
                    
| 結果 | 
                             
                                RE
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 810 bytes | 
| コンパイル時間 | 295 ms | 
| コンパイル使用メモリ | 82,304 KB | 
| 実行使用メモリ | 92,804 KB | 
| 平均クエリ数 | 170.33 | 
| 最終ジャッジ日時 | 2024-12-21 01:09:35 | 
| 合計ジャッジ時間 | 8,972 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge5 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | RE * 1 | 
| other | AC * 2 WA * 1 RE * 26 | 
ソースコード
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
        if ans[i]==25:
            phrase=get_password(ans)
            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