結果

問題 No.850 企業コンテスト2位
ユーザー tktk_snsn
提出日時 2022-05-17 06:03:31
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 66 ms / 2,000 ms
コード長 684 bytes
コンパイル時間 108 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 27,480 KB
平均クエリ数 200.11
最終ジャッジ日時 2024-09-14 23:28:22
合計ジャッジ時間 3,806 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 27
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque


def find(P):
    N = len(P)
    win = [[] for _ in range(N)]
    que = deque(list(range(N)))
    while len(que) > 1:
        a = que.popleft()
        b = que.popleft()
        if a > b:
            que.append(a)
            que.appendleft(b)
            continue

        print("? {} {}".format(P[a], P[b]))
        x = int(input())

        if x == P[a]:
            que.append(a)
            win[a].append(b)
        else:
            que.append(b)
            win[b].append(a)

    i = que.pop()
    L = [P[j] for j in win[i]]
    return P[i], L


N = int(input())
X = list(range(1, N + 1))

T1, Y = find(X)
T2, Z = find(Y)
print("! {}".format(T2))
0