結果
問題 | No.253 ロウソクの長さ |
ユーザー |
![]() |
提出日時 | 2020-03-04 11:49:29 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 66 ms / 2,000 ms |
コード長 | 1,840 bytes |
コンパイル時間 | 256 ms |
コンパイル使用メモリ | 12,928 KB |
実行使用メモリ | 27,736 KB |
平均クエリ数 | 29.47 |
最終ジャッジ日時 | 2024-07-17 02:35:12 |
合計ジャッジ時間 | 4,276 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 36 |
ソースコード
#!/usr/bin/env python3# %%import sysreadline = sys.stdin.readline# %%DEBUG = TrueDEBUG = False# %%class Interactive:def __init__(self):self.ques_cnt = 0self.create_data()def create_data(self):import randomself.ans = random.randint(10, 10 ** 9)self.x = self.ans + 1print('created', self.x)def resp_ques(self, *args):self.x -= 1if self.x < 0:self.x = 0x = int(args[0])if x < self.x:return '1\n'elif x == self.x:return '0\n'else:return '-1\n'def resp_ans(self, *args):x = int(args[0])if x == self.ans: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 respelse: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 first_strategy():resp = int(question(80))if resp == 0:answer(80)if resp == 1:returnk = 1while True:resp = int(question(5))if resp == 0:answer(5 + k)k += 1# %%first_strategy()k = 0left = 1right = 10 ** 9 + 1while left + 1 < right:k += 1x = (left + right) // 2resp = int(question(x - k))if resp == 0:answer(x)breakif resp == -1:right = xif resp == 1:left = x