結果

問題 No.3212 SUPER Guess the Number
コンテスト
ユーザー detteiuu
提出日時 2025-07-26 02:18:29
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 194 ms / 2,000 ms
+ 2µs
コード長 625 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 233 ms
コンパイル使用メモリ 95,976 KB
実行使用メモリ 78,664 KB
平均クエリ数 23.92
最終ジャッジ日時 2026-07-13 13:56:55
合計ジャッジ時間 2,263 ms
ジャッジサーバーID
(参考情報)
judge2_1 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 12
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

def question(x):
    print("?", x)
    OUTPUT.append(x)
    if 2 <= len(OUTPUT):
        return int(input())
def answer(a):
    print("!", a)

OUTPUT = []
l, r = 1, 10**6
question(l)
ans = question(r)
if ans == 0:
    r = (l+r)//2
else:
    l = (l+r+1)//2
while l+1 < r:
    p = OUTPUT[-1]
    mid = (l+r)//2
    ans = question(p+(mid-p)*2)
    if ans == 0:
        if OUTPUT[-2] < OUTPUT[-1]:
            r = mid
        else:
            l = mid
    else:
        if OUTPUT[-2] < OUTPUT[-1]:
            l = mid
        else:
            r = mid

question(l)
ans = question(r)
if ans == 0:
    answer(l)
else:
    answer(r)
0