結果

問題 No.1830 Balanced Majority
ユーザー titiatitia
提出日時 2022-02-06 00:39:09
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
実行時間 -
コード長 607 bytes
コンパイル時間 347 ms
コンパイル使用メモリ 10,944 KB
実行使用メモリ 24,428 KB
平均クエリ数 8.88
最終ジャッジ日時 2023-09-02 06:53:34
合計ジャッジ時間 2,935 ms
ジャッジサーバーID
(参考情報)
judge11 / judge16
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
24,048 KB
testcase_01 AC 36 ms
24,136 KB
testcase_02 AC 36 ms
23,560 KB
testcase_03 AC 37 ms
23,652 KB
testcase_04 AC 37 ms
24,324 KB
testcase_05 AC 37 ms
23,960 KB
testcase_06 RE -
testcase_07 AC 39 ms
24,428 KB
testcase_08 AC 39 ms
24,288 KB
testcase_09 AC 39 ms
23,920 KB
testcase_10 AC 37 ms
23,884 KB
testcase_11 RE -
testcase_12 AC 38 ms
24,060 KB
testcase_13 AC 38 ms
23,552 KB
testcase_14 AC 38 ms
24,372 KB
testcase_15 AC 39 ms
24,060 KB
testcase_16 AC 41 ms
23,880 KB
testcase_17 AC 38 ms
23,984 KB
testcase_18 AC 36 ms
24,004 KB
testcase_19 AC 35 ms
24,052 KB
testcase_20 RE -
testcase_21 AC 39 ms
24,060 KB
testcase_22 RE -
testcase_23 RE -
testcase_24 AC 39 ms
23,716 KB
testcase_25 AC 35 ms
24,372 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

N=int(input())

print("?",1,flush=True)
x=int(input())
print("?",N-1,flush=True)
y=int(input())

if x==1 and y==N//2:
    print("!",2,N-1,flush=True)
    exit()
elif x==0 and y==N//2-1:
    print("!",2,N-1,flush=True)
    exit()

# 1~xの表 - 裏の枚数が0になるものを探す

MIN=2
MAX=N-1

while True:
    mid=(MIN+MAX)//2

    print("?",mid,flush=True)
    x=int(input())
    y=mid-x

    if x<y:
        MAX=mid
    elif x>y:
        MIN=mid
    else:
        break

if mid>=N//2:
    print("!",1,mid,flush=True)
else:
    print("!",mid+1,N,flush=True)
0