結果

問題 No.850 企業コンテスト2位
ユーザー convexineqconvexineq
提出日時 2019-07-05 23:29:41
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 51 ms / 2,000 ms
コード長 799 bytes
コンパイル時間 128 ms
コンパイル使用メモリ 10,684 KB
実行使用メモリ 24,276 KB
平均クエリ数 200.07
最終ジャッジ日時 2023-09-23 17:42:54
合計ジャッジ時間 3,034 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
24,252 KB
testcase_01 AC 39 ms
23,952 KB
testcase_02 AC 37 ms
23,400 KB
testcase_03 AC 38 ms
23,524 KB
testcase_04 AC 37 ms
23,520 KB
testcase_05 AC 37 ms
23,628 KB
testcase_06 AC 40 ms
23,496 KB
testcase_07 AC 42 ms
23,820 KB
testcase_08 AC 43 ms
24,276 KB
testcase_09 AC 42 ms
23,420 KB
testcase_10 AC 47 ms
24,276 KB
testcase_11 AC 49 ms
23,976 KB
testcase_12 AC 49 ms
23,304 KB
testcase_13 AC 49 ms
23,988 KB
testcase_14 AC 48 ms
23,352 KB
testcase_15 AC 49 ms
23,976 KB
testcase_16 AC 47 ms
23,628 KB
testcase_17 AC 49 ms
24,192 KB
testcase_18 AC 48 ms
23,976 KB
testcase_19 AC 49 ms
23,424 KB
testcase_20 AC 50 ms
23,640 KB
testcase_21 AC 50 ms
23,352 KB
testcase_22 AC 50 ms
23,304 KB
testcase_23 AC 51 ms
24,132 KB
testcase_24 AC 51 ms
23,880 KB
testcase_25 AC 50 ms
23,428 KB
testcase_26 AC 48 ms
24,264 KB
testcase_27 AC 37 ms
23,556 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# coding: utf-8
# Your code here!

import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline #文字列入力のときは注意

n=int(input())

cand = [[i] for i in range(1,n+1)]
while len(cand) > 1:
    cand2 = []
    while len(cand) > 1:
        a = cand.pop()
        b = cand.pop()
        print("?", a[0], b[0])
        sys.stdout.flush()
        res = int(input())
        if res == a[0]:
            a.append(b[0])
            cand2.append(a)
        else:
            b.append(a[0])
            cand2.append(b)
    if cand: cand2.append(cand[0])
    cand = cand2

cand = cand[0]
cand.pop(0)

ans = cand.pop()
while cand:
    c = cand.pop()
    print("?", ans, c)
    sys.stdout.flush()
    res = int(input())
    if res == c: ans = c

print("!", ans)    
    
    
    
    



0