結果

問題 No.850 企業コンテスト2位
ユーザー lemondolemondo
提出日時 2023-11-29 00:02:05
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 72 ms / 2,000 ms
コード長 872 bytes
コンパイル時間 210 ms
コンパイル使用メモリ 12,032 KB
実行使用メモリ 26,112 KB
平均クエリ数 200.07
最終ジャッジ日時 2023-11-29 00:02:09
合計ジャッジ時間 3,864 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 51 ms
26,112 KB
testcase_01 AC 47 ms
26,112 KB
testcase_02 AC 47 ms
26,112 KB
testcase_03 AC 50 ms
26,112 KB
testcase_04 AC 46 ms
26,112 KB
testcase_05 AC 47 ms
26,112 KB
testcase_06 AC 48 ms
26,112 KB
testcase_07 AC 52 ms
26,112 KB
testcase_08 AC 54 ms
26,112 KB
testcase_09 AC 54 ms
26,112 KB
testcase_10 AC 60 ms
26,112 KB
testcase_11 AC 58 ms
26,112 KB
testcase_12 AC 60 ms
26,112 KB
testcase_13 AC 58 ms
26,112 KB
testcase_14 AC 61 ms
26,112 KB
testcase_15 AC 59 ms
26,112 KB
testcase_16 AC 58 ms
26,112 KB
testcase_17 AC 58 ms
26,112 KB
testcase_18 AC 60 ms
26,112 KB
testcase_19 AC 58 ms
26,112 KB
testcase_20 AC 59 ms
26,112 KB
testcase_21 AC 72 ms
26,112 KB
testcase_22 AC 60 ms
26,112 KB
testcase_23 AC 60 ms
26,112 KB
testcase_24 AC 61 ms
26,112 KB
testcase_25 AC 62 ms
26,112 KB
testcase_26 AC 63 ms
26,112 KB
testcase_27 AC 52 ms
26,112 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return list(map(int, input().split()))
sys.setrecursionlimit(10**9)

N = int(input())

from collections import defaultdict
remains = list(range(1, N+1))
lost_by = defaultdict(list)

def f(remains):
    while(len(remains)!=1):
        nx_remains = []
        if(len(remains)%2==1):
            nx_remains.append(remains[-1])
        for i in range(0, len(remains)-1, 2):
            a = remains[i]
            b = remains[i+1]
            print(f"? {a} {b}", flush=True)
            ret = int(input())
            if(ret==a):
                nx_remains.append(a)
                lost_by[a].append(b)
            else:
                nx_remains.append(b)
                lost_by[b].append(a)
        remains = nx_remains
    return remains[0]
    
first = f(remains)
print(f"! {f(lost_by[first])}")
0