結果

問題 No.1830 Balanced Majority
ユーザー chineristACchineristAC
提出日時 2021-12-28 01:40:04
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 964 bytes
コンパイル時間 364 ms
コンパイル使用メモリ 82,436 KB
実行使用メモリ 85,372 KB
平均クエリ数 8.42
最終ジャッジ日時 2024-04-17 06:44:38
合計ジャッジ時間 4,027 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 68 ms
73,060 KB
testcase_01 AC 66 ms
72,360 KB
testcase_02 AC 66 ms
72,920 KB
testcase_03 AC 67 ms
73,596 KB
testcase_04 AC 64 ms
72,836 KB
testcase_05 AC 66 ms
72,492 KB
testcase_06 AC 66 ms
73,332 KB
testcase_07 AC 67 ms
73,040 KB
testcase_08 AC 66 ms
72,388 KB
testcase_09 AC 67 ms
72,740 KB
testcase_10 AC 67 ms
72,840 KB
testcase_11 AC 69 ms
73,052 KB
testcase_12 AC 67 ms
74,396 KB
testcase_13 RE -
testcase_14 AC 68 ms
73,288 KB
testcase_15 AC 66 ms
72,948 KB
testcase_16 AC 66 ms
72,584 KB
testcase_17 AC 66 ms
72,816 KB
testcase_18 AC 64 ms
73,012 KB
testcase_19 AC 65 ms
73,232 KB
testcase_20 AC 66 ms
73,668 KB
testcase_21 AC 68 ms
73,224 KB
testcase_22 AC 67 ms
72,968 KB
testcase_23 RE -
testcase_24 AC 66 ms
74,196 KB
testcase_25 AC 64 ms
74,160 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from os import cpu_count
import sys,random,bisect
from collections import deque,defaultdict
from heapq import heapify,heappop,heappush
from itertools import permutations
from math import log,gcd

input = lambda :sys.stdin.readline().rstrip()
mi = lambda :map(int,input().split())
li = lambda :list(mi())

def query(k):
    print("? {}".format(k))
    sys.stdout.flush()
    res = int(input())
    assert res!=-1
    return res

def answer(l,r):
    print("! {} {}".format(l,r))
    sys.stdout.flush()

N = int(input())

if query(1)==1:
    first = 1
else:
    first = 0
query(N)
if query(N-1)==N//2-1:
    end = 1
else:
    end = 0

if first!=end:
    exit(answer(2,N-1))

f_L = 2*first - 1
f_R = 2*(N//2 - end) - (N-1)

L = 1
R = N
while R-L > 1:
    mid = (L+R)//2
    check = 2 * query(mid) - mid

    if f_L * check >= 0:
        L = mid
        if check==0:
            break
    else:
        R = mid

if N//2 <= L:
    answer(1,L)
else:
    answer(L+1,N)


0