結果
| 問題 | No.253 ロウソクの長さ | 
| コンテスト | |
| ユーザー |  maspy | 
| 提出日時 | 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 sys
readline = sys.stdin.readline
# %%
DEBUG = True
DEBUG = False
# %%
class Interactive:
    def __init__(self):
        self.ques_cnt = 0
        self.create_data()
    def create_data(self):
        import random
        self.ans = random.randint(10, 10 ** 9)
        self.x = self.ans + 1
        print('created', self.x)
    def resp_ques(self, *args):
        self.x -= 1
        if self.x < 0:
            self.x = 0
        x = 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 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 first_strategy():
    resp = int(question(80))
    if resp == 0:
        answer(80)
    if resp == 1:
        return
    k = 1
    while True:
        resp = int(question(5))
        if resp == 0:
            answer(5 + k)
        k += 1
# %%
first_strategy()
k = 0
left = 1
right = 10 ** 9 + 1
while left + 1 < right:
    k += 1
    x = (left + right) // 2
    resp = int(question(x - k))
    if resp == 0:
        answer(x)
        break
    if resp == -1:
        right = x
    if resp == 1:
        left = x
            
            
            
        