結果

問題 No.850 企業コンテスト2位
ユーザー tamatotamato
提出日時 2021-08-13 09:25:10
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 78 ms / 2,000 ms
コード長 803 bytes
コンパイル時間 254 ms
コンパイル使用メモリ 82,664 KB
実行使用メモリ 77,396 KB
平均クエリ数 200.11
最終ジャッジ日時 2024-04-10 15:36:25
合計ジャッジ時間 4,062 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 58 ms
69,368 KB
testcase_01 AC 57 ms
69,612 KB
testcase_02 AC 56 ms
70,472 KB
testcase_03 AC 55 ms
69,840 KB
testcase_04 AC 56 ms
69,492 KB
testcase_05 AC 56 ms
70,244 KB
testcase_06 AC 56 ms
69,632 KB
testcase_07 AC 63 ms
69,828 KB
testcase_08 AC 66 ms
70,492 KB
testcase_09 AC 64 ms
70,992 KB
testcase_10 AC 77 ms
76,084 KB
testcase_11 AC 76 ms
76,900 KB
testcase_12 AC 75 ms
77,124 KB
testcase_13 AC 74 ms
76,776 KB
testcase_14 AC 74 ms
76,128 KB
testcase_15 AC 73 ms
76,416 KB
testcase_16 AC 73 ms
76,524 KB
testcase_17 AC 74 ms
76,712 KB
testcase_18 AC 71 ms
76,048 KB
testcase_19 AC 73 ms
76,536 KB
testcase_20 AC 75 ms
76,568 KB
testcase_21 AC 73 ms
77,392 KB
testcase_22 AC 78 ms
77,396 KB
testcase_23 AC 75 ms
76,432 KB
testcase_24 AC 77 ms
75,960 KB
testcase_25 AC 74 ms
76,368 KB
testcase_26 AC 72 ms
77,328 KB
testcase_27 AC 57 ms
70,288 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline

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

    N = int(input())
    st = list(range(1, N+1))
    op = [[] for _ in range(N+1)]
    while len(st) > 1:
        st_new = []
        for i in range(len(st) // 2):
            x = st[i * 2]
            y = st[i * 2 + 1]
            op[x].append(y)
            op[y].append(x)
            z = ask(x, y)
            st_new.append(z)
        if len(st) & 1:
            st_new.append(st[-1])
        st = st_new
    first = st[0]
    second_list = op[first]
    x = second_list[0]
    for y in second_list[1:]:
        x = ask(x, y)
    print("!", x)
    sys.stdout.flush()


if __name__ == '__main__':
    main()
0