結果

問題 No.3212 SUPER Guess the Number
ユーザー miya145592
提出日時 2025-07-27 03:58:27
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 64 ms / 2,000 ms
コード長 739 bytes
コンパイル時間 440 ms
コンパイル使用メモリ 82,032 KB
実行使用メモリ 71,136 KB
平均クエリ数 23.00
最終ジャッジ日時 2025-07-27 03:58:30
合計ジャッジ時間 2,377 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 12
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
l = 0
r = 10**6
pre = (r-l)//2
print("?", pre, flush=True)
for _ in range(24):
    c = (l+r)//2
    dif = c-pre
    now = c+dif
    if dif==0:
        now += 1
    #print(l, r, pre, now)
    print("?", now, flush=True)
    ret = int(input())
    if ret==-1:
        exit()
    if pre<now:
        if ret==1:
            c = (pre+now+1)//2
            l = c
            pre = now
        else:
            c = (pre+now+1)//2
            r = c-1
            pre = now
    else:
        if ret==1:
            c = (pre+now)//2
            r = c
            pre = now
        else:
            c = (pre+now)//2
            l = c+1
            pre = now
    if l==r:
        break
print("!", l, flush=True)
0