結果
| 問題 |
No.1830 Balanced Majority
|
| コンテスト | |
| ユーザー |
titia
|
| 提出日時 | 2022-02-06 00:47:25 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 47 ms / 2,000 ms |
| コード長 | 779 bytes |
| コンパイル時間 | 297 ms |
| コンパイル使用メモリ | 12,672 KB |
| 実行使用メモリ | 27,608 KB |
| 平均クエリ数 | 7.42 |
| 最終ジャッジ日時 | 2024-06-11 13:42:20 |
| 合計ジャッジ時間 | 2,991 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 25 |
ソースコード
import sys
input = sys.stdin.readline
N=int(input())
print("?",1,flush=True)
x=int(input())
init=x
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 init==1:
if x<y:
MAX=mid
elif x>y:
MIN=mid
else:
break
else:
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)
titia