結果

問題 No.850 企業コンテスト2位
ユーザー chineristACchineristAC
提出日時 2020-10-19 18:34:01
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 146 ms / 2,000 ms
コード長 643 bytes
コンパイル時間 790 ms
コンパイル使用メモリ 87,056 KB
実行使用メモリ 92,912 KB
平均クエリ数 200.11
最終ジャッジ日時 2023-09-24 06:53:02
合計ジャッジ時間 6,126 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 128 ms
87,396 KB
testcase_01 AC 118 ms
87,504 KB
testcase_02 AC 117 ms
87,772 KB
testcase_03 AC 115 ms
87,168 KB
testcase_04 AC 116 ms
87,420 KB
testcase_05 AC 119 ms
87,600 KB
testcase_06 AC 118 ms
87,512 KB
testcase_07 AC 127 ms
87,476 KB
testcase_08 AC 132 ms
88,048 KB
testcase_09 AC 131 ms
88,184 KB
testcase_10 AC 146 ms
92,132 KB
testcase_11 AC 141 ms
92,912 KB
testcase_12 AC 139 ms
91,772 KB
testcase_13 AC 140 ms
92,128 KB
testcase_14 AC 142 ms
92,180 KB
testcase_15 AC 139 ms
92,552 KB
testcase_16 AC 139 ms
92,420 KB
testcase_17 AC 142 ms
92,516 KB
testcase_18 AC 139 ms
91,968 KB
testcase_19 AC 140 ms
92,168 KB
testcase_20 AC 143 ms
91,868 KB
testcase_21 AC 143 ms
92,340 KB
testcase_22 AC 143 ms
92,372 KB
testcase_23 AC 142 ms
92,164 KB
testcase_24 AC 139 ms
92,228 KB
testcase_25 AC 139 ms
92,048 KB
testcase_26 AC 144 ms
92,304 KB
testcase_27 AC 120 ms
88,084 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

def query(x,y):
    print("?",x,y)
    sys.stdout.flush()
    return int(input())

from collections import deque

N = int(input())
deq = deque([i for i in range(1,N+1)])

win = [[] for  i in range(N+1)]

while len(deq)>1:
    ndeq = deque([])
    while deq:
        x = deq.popleft()
        if not deq:
            ndeq.append(x)
            break
        y = deq.popleft()
        z = query(x,y)
        if z==x:
            win[x].append(y)
        else:
            win[y].append(x)
        ndeq.append(z)
    deq = ndeq

one = deq[0]

L = win[one]
res = L[0]
for i in range(1,len(L)):
    res = query(res,L[i])

print("!",res)
0