結果

問題 No.246 質問と回答
ユーザー maspymaspy
提出日時 2020-01-22 18:51:14
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 61 ms / 2,000 ms
コード長 1,571 bytes
コンパイル時間 74 ms
コンパイル使用メモリ 11,000 KB
実行使用メモリ 24,600 KB
平均クエリ数 30.90
最終ジャッジ日時 2023-09-23 20:33:14
合計ジャッジ時間 3,770 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 61 ms
24,568 KB
testcase_01 AC 58 ms
24,452 KB
testcase_02 AC 58 ms
24,208 KB
testcase_03 AC 58 ms
24,008 KB
testcase_04 AC 59 ms
24,000 KB
testcase_05 AC 58 ms
23,900 KB
testcase_06 AC 59 ms
24,420 KB
testcase_07 AC 59 ms
24,032 KB
testcase_08 AC 58 ms
24,560 KB
testcase_09 AC 58 ms
23,776 KB
testcase_10 AC 61 ms
23,984 KB
testcase_11 AC 59 ms
23,952 KB
testcase_12 AC 58 ms
24,192 KB
testcase_13 AC 59 ms
23,996 KB
testcase_14 AC 60 ms
24,016 KB
testcase_15 AC 60 ms
24,396 KB
testcase_16 AC 60 ms
24,484 KB
testcase_17 AC 60 ms
24,292 KB
testcase_18 AC 58 ms
24,600 KB
testcase_19 AC 58 ms
24,156 KB
testcase_20 AC 59 ms
24,536 KB
testcase_21 AC 58 ms
24,152 KB
testcase_22 AC 58 ms
23,856 KB
testcase_23 AC 59 ms
24,212 KB
testcase_24 AC 59 ms
24,568 KB
testcase_25 AC 60 ms
24,484 KB
testcase_26 AC 59 ms
23,976 KB
testcase_27 AC 59 ms
24,592 KB
testcase_28 AC 59 ms
24,304 KB
testcase_29 AC 59 ms
24,112 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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
        x = random.randint(1, 10**9)
        self.x = x
        print('created:', x)
        
    def resp_ques(self, *args):
        self.ques_cnt += 1
        if len(args) != 1:
            raise ValueError
        y = args[0]
        if self.x >= y:
            return '1\n'
        else:
            return '0\n'
            
    def resp_ans(self, *args):
        if len(args) != 1:
            raise ValueError
        y = args[0]
        if self.x == y:
            print('AC!')
            print('ques_cnt:', self.ques_cnt)
        else:
            print('WA')
            
if DEBUG:
    interactive = Interactive()
    
def question(*args, offset=None):
    if offset is None:
        print(*args, flush=True)
    else:
        print(offset, *args, flush=True)
    if DEBUG:
        resp = interactive.resp_ques(*args)
        print(resp)
        return resp
    else:
        return readline()
    
def answer(*args, offset=None):
    if offset is None:
        print(*args, flush=True)
    else:
        print(offset, *args, flush=True)
    if DEBUG:
        interactive.resp_ans(*args)
    else:
        exit()

left = 0
right = 10**9 + 10 # xより大きい
while left + 1 < right:
    x = (left+right) // 2
    resp = int(question(x, offset='?'))
    if resp:
        left = x
    else:
        right = x

answer(left, offset='!')
0