#!/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)