結果

問題 No.3161 Find Presents
ユーザー detteiuu
提出日時 2025-05-23 20:41:55
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 318 ms / 4,000 ms
コード長 865 bytes
コンパイル時間 253 ms
コンパイル使用メモリ 82,048 KB
実行使用メモリ 94,664 KB
平均クエリ数 2112.10
最終ジャッジ日時 2025-05-23 20:42:17
合計ジャッジ時間 19,623 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 80
権限があれば一括ダウンロードができます

ソースコード

diff #

def question(xl, xr, yl, yr):
    print("?", xl, xr, yl, yr)
    ans = int(input())
    if ans == -1:
        exit()
    return ans == 1

A = []
left = 0
while left <= 10**6 and question(left, 10**6, 0, 10**6):
    l = left
    r = 10**6
    while l+1 < r:
        m = (l+r)//2
        if not question(l, m, 0, 10**6):
            l = m+1
        else:
            r = m
    if not question(l, l, 0, 10**6):
        l += 1
    left2 = 0
    while left2 <= 10**6 and question(l, l, left2, 10**6):
        l2 = left2
        r2 = 10**6
        while l2+1 < r2:
            m = (l2+r2)//2
            if not question(l, l, l2, m):
                l2 = m+1
            else:
                r2 = m
        if not question(l, l, l2, l2):
            l2 += 1
        A.append((l, l2))
        left2 = l2+1
    left = l+1

print("!", len(A))
for X, Y in A:
    print(X, Y)
0