結果

問題 No.850 企業コンテスト2位
ユーザー 👑 rin204rin204
提出日時 2022-11-02 23:12:39
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 123 ms / 2,000 ms
コード長 749 bytes
コンパイル時間 282 ms
コンパイル使用メモリ 87,136 KB
実行使用メモリ 91,716 KB
平均クエリ数 200.46
最終ジャッジ日時 2023-09-24 10:19:06
合計ジャッジ時間 5,615 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 101 ms
87,488 KB
testcase_01 AC 95 ms
87,108 KB
testcase_02 AC 98 ms
87,012 KB
testcase_03 AC 97 ms
87,108 KB
testcase_04 AC 97 ms
87,552 KB
testcase_05 AC 97 ms
87,396 KB
testcase_06 AC 98 ms
86,924 KB
testcase_07 AC 106 ms
87,264 KB
testcase_08 AC 110 ms
87,764 KB
testcase_09 AC 108 ms
87,264 KB
testcase_10 AC 121 ms
91,140 KB
testcase_11 AC 122 ms
91,648 KB
testcase_12 AC 121 ms
91,512 KB
testcase_13 AC 121 ms
91,524 KB
testcase_14 AC 119 ms
91,716 KB
testcase_15 AC 119 ms
91,012 KB
testcase_16 AC 117 ms
91,148 KB
testcase_17 AC 123 ms
91,596 KB
testcase_18 AC 119 ms
91,468 KB
testcase_19 AC 119 ms
91,632 KB
testcase_20 AC 118 ms
90,868 KB
testcase_21 AC 119 ms
91,028 KB
testcase_22 AC 120 ms
91,208 KB
testcase_23 AC 120 ms
91,672 KB
testcase_24 AC 121 ms
91,044 KB
testcase_25 AC 120 ms
91,100 KB
testcase_26 AC 120 ms
90,964 KB
testcase_27 AC 97 ms
87,168 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def ask(x, y):
    print("?", x + 1, y + 1, flush=True)
    return int(input()) - 1

def judge(x):
    print("!", x + 1)
    exit()

n = int(input())
A = [i for i in range(n)]
vs = [-1] * n
while len(A) >= 2:
    B = []
    while len(A) >= 2:
        x = A.pop()
        y = A.pop()
        z = ask(x, y)
        B.append(z)
        if x == z:
            vs[y] = x
        else:
            vs[x] = y
            
    A += B

x = A[0]
A = []
for i in range(n):
    if vs[i] == x:
        A.append(i)

while len(A) >= 2:
    B = []
    while len(A) >= 2:
        x = A.pop()
        y = A.pop()
        z = ask(x, y)
        B.append(z)
        if x == z:
            vs[y] = x
        else:
            vs[x] = y
            
    A += B
judge(A[0])
0