結果
問題 | No.594 壊れた宝物発見機 |
ユーザー |
![]() |
提出日時 | 2020-02-29 20:11:26 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 148 ms / 2,000 ms |
コード長 | 1,749 bytes |
コンパイル時間 | 247 ms |
コンパイル使用メモリ | 12,928 KB |
実行使用メモリ | 27,616 KB |
平均クエリ数 | 44.70 |
最終ジャッジ日時 | 2024-07-16 20:30:37 |
合計ジャッジ時間 | 4,514 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 20 |
ソースコード
#!/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)