結果
| 問題 |
No.1830 Balanced Majority
|
| コンテスト | |
| ユーザー |
👑 Kazun
|
| 提出日時 | 2022-02-05 10:02:54 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 940 bytes |
| コンパイル時間 | 228 ms |
| コンパイル使用メモリ | 82,432 KB |
| 実行使用メモリ | 72,980 KB |
| 平均クエリ数 | 8.65 |
| 最終ジャッジ日時 | 2024-06-11 13:23:04 |
| 合計ジャッジ時間 | 3,150 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 20 WA * 5 |
ソースコード
def question(K):
print("?",K,flush=True)
S=int(input())
T[K]=S-(K-S)
def answer(L,R):
print("!",L,R,flush=True)
exit()
def General_Binary_Increase_Search_Integer(L,R,cond,default=None):
"""条件式が単調増加であるとき, 整数上で二部探索を行う.
L: 解の下限
R: 解の上限
cond: 条件(1変数関数, 広義単調増加を満たす)
default: Lで条件を満たさないときの返り値
"""
#if not(cond(R)): return default
if cond(L): return L
R+=1
while R-L>1:
C=L+(R-L)//2
if cond(C): R=C
else: L=C
return R
def check(x):
question(x)
return T[x]*T[N-1]>=0
#==================================================
N=int(input())
T=[None]*(N+1)
question(1); question(N-1)
if T[1]==T[N-1]:
answer(2,N-1)
M=General_Binary_Increase_Search_Integer(2,N-1,check)
if N//2<=M:
answer(1,M)
else:
answer(M+1,N)
Kazun