結果

問題 No.850 企業コンテスト2位
ユーザー maspymaspy
提出日時 2020-03-31 12:12:47
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 1,703 bytes
コンパイル時間 86 ms
コンパイル使用メモリ 10,924 KB
実行使用メモリ 24,652 KB
平均クエリ数 197.50
最終ジャッジ日時 2023-09-24 03:15:21
合計ジャッジ時間 5,794 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 38 ms
24,600 KB
testcase_03 AC 38 ms
24,292 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 32 ms
24,020 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 33 ms
24,640 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/ python3.8
import sys
readline = sys.stdin.readline

# DEBUG = True
DEBUG = False

N = int(readline())


class Interactive:
    def __init__(self):
        self.ques_cnt = 0
        self.create_data()

    def create_data(self):
        import numpy as np
        rank = np.arange(N + 1)
        np.random.shuffle(rank[1:])
        self.rank = rank
        print('created', rank)

    def resp_ques(self, *args):
        x, y = args
        ret = x if self.rank[x] < self.rank[y] else y
        return str(ret) + '\n'

    def resp_ans(self, *args):
        x = args
        if self.rank[x] == 2:
            print('AC')
        else:
            print('WA')


if DEBUG:
    interactive = Interactive()


def question(*args, offset='?'):
    if offset is None:
        print(*args, flush=True)
    else:
        print(offset, *args, flush=True)
    if DEBUG:
        resp = interactive.resp_ques(*args)
        print(resp, end='')
        return resp
    else:
        return readline()


def answer(*args, offset='!'):
    if offset is None:
        print(*args, flush=True)
    else:
        print(offset, *args, flush=True)
    if DEBUG:
        interactive.resp_ans(*args)
    else:
        exit()


log = []
A = list(range(1, N + 1))
while len(A) >= 2:
    B = []
    it = iter(A)
    for x, y in zip(it, it):
        ret = int(question(x, y))
        log.append((x, y, ret))
        B.append(ret)
    A = B

best_x = A[0]
A = []
for x, y, z in log:
    if z == best_x:
        A.append(x + y - z)

while len(A) >= 2:
    B = []
    it = iter(A)
    for x, y in zip(it, it):
        ret = int(question(x, y))
        log.append((x, y, ret))
        B.append(ret)
    A = B

answer(A[0])
0