結果

問題 No.594 壊れた宝物発見機
ユーザー maspymaspy
提出日時 2020-02-29 20:10:32
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 1,749 bytes
コンパイル時間 74 ms
コンパイル使用メモリ 10,752 KB
実行使用メモリ 25,632 KB
平均クエリ数 89.70
最終ジャッジ日時 2023-09-23 20:40:33
合計ジャッジ時間 4,559 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
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 -
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env python3
# %%
import sys
readline = sys.stdin.readline
from functools import lru_cache

# %%
DEBUG = True
# DEBUG = False

# %%


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

    def create_data(self):
        import random
        x, y, z = [random.randint(-150, 151) for _ in range(3)]
        print('created', x, y, z)
        self.x = x
        self.y = y
        self.z = z

    def resp_ques(self, *args):
        x, y, z = args
        d = (self.x - x) ** 2 + (self.y - y) ** 2 + (self.z - z) ** 2
        return f'{d}\n'

    def resp_ans(self, *args):
        x, y, z = args
        if x == self.x and y == self.y and z == self.z:
            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()


# %%
def find_kth_coord(k):
    @lru_cache(None)
    def f(x):
        values = [0, 0, 0]
        values[k] = x
        resp = int(question(*values))
        return resp
    left = -151
    right = 150
    while left + 1 < right:
        x = (left + right) // 2
        if f(x) < f(x + 1):
            right = x
        else:
            left = x
    return right


# %%
x, y, z = [find_kth_coord(k) for k in [0, 1, 2]]
answer(x, y, z)
0