結果

問題 No.850 企業コンテスト2位
ユーザー titiatitia
提出日時 2019-07-12 16:58:16
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
AC  
実行時間 52 ms / 2,000 ms
コード長 1,250 bytes
コンパイル時間 771 ms
コンパイル使用メモリ 10,932 KB
実行使用メモリ 24,540 KB
平均クエリ数 200.11
最終ジャッジ日時 2023-09-23 17:54:45
合計ジャッジ時間 3,930 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
24,332 KB
testcase_01 AC 37 ms
24,396 KB
testcase_02 AC 36 ms
23,716 KB
testcase_03 AC 34 ms
23,976 KB
testcase_04 AC 40 ms
23,880 KB
testcase_05 AC 37 ms
24,032 KB
testcase_06 AC 37 ms
23,864 KB
testcase_07 AC 43 ms
24,140 KB
testcase_08 AC 44 ms
24,024 KB
testcase_09 AC 45 ms
24,024 KB
testcase_10 AC 50 ms
24,116 KB
testcase_11 AC 49 ms
24,120 KB
testcase_12 AC 51 ms
24,236 KB
testcase_13 AC 48 ms
24,540 KB
testcase_14 AC 50 ms
24,428 KB
testcase_15 AC 50 ms
23,796 KB
testcase_16 AC 50 ms
23,936 KB
testcase_17 AC 52 ms
24,392 KB
testcase_18 AC 50 ms
24,412 KB
testcase_19 AC 51 ms
23,808 KB
testcase_20 AC 51 ms
23,852 KB
testcase_21 AC 50 ms
24,432 KB
testcase_22 AC 50 ms
24,280 KB
testcase_23 AC 51 ms
24,132 KB
testcase_24 AC 51 ms
24,368 KB
testcase_25 AC 50 ms
23,956 KB
testcase_26 AC 51 ms
24,164 KB
testcase_27 AC 38 ms
23,820 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N=int(input())

TOURNAMENT=[list(range(1,N+1))]
WINLIST=[]

while len(TOURNAMENT[-1])!=1:
    LEN=len(TOURNAMENT[-1])
    NEXT=[]

    for i in range(0,LEN,2):

        if i==LEN-1:
            NEXT.append(TOURNAMENT[-1][i])
            break

        x=TOURNAMENT[-1][i]
        y=TOURNAMENT[-1][i+1]

        print("?",x,y,flush=True)
        win=int(input())

        if x==win:
            NEXT.append(x)
            WINLIST.append([x,y])
        else:
            NEXT.append(y)
            WINLIST.append([y,x])
            

    TOURNAMENT.extend([NEXT])

WIN1=TOURNAMENT[-1][-1]

TOURNAMENT2=[]
for x,y in WINLIST:
    if x==WIN1:
        TOURNAMENT2.append(y)
    

TOURNAMENT=[TOURNAMENT2]
     
while len(TOURNAMENT[-1])!=1:
    LEN=len(TOURNAMENT[-1])
    NEXT=[]

    for i in range(0,LEN,2):

        if i==LEN-1:
            NEXT.append(TOURNAMENT[-1][i])
            break

        x=TOURNAMENT[-1][i]
        y=TOURNAMENT[-1][i+1]

        print("?",x,y,flush=True)
        win=int(input())

        if x==win:
            NEXT.append(x)
            WINLIST.append([x,y])
        else:
            NEXT.append(y)
            WINLIST.append([y,x])
            

    TOURNAMENT.extend([NEXT])

print("!",TOURNAMENT[-1][-1],flush=True)
0