結果

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

ソースコード

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