結果

問題 No.513 宝探し2
ユーザー kichirb3kichirb3
提出日時 2018-03-08 19:41:58
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 41 ms / 2,000 ms
コード長 988 bytes
コンパイル時間 98 ms
コンパイル使用メモリ 10,912 KB
実行使用メモリ 24,240 KB
平均クエリ数 9.33
最終ジャッジ日時 2023-09-24 01:39:55
合計ジャッジ時間 1,620 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
23,940 KB
testcase_01 AC 39 ms
23,700 KB
testcase_02 AC 39 ms
23,928 KB
testcase_03 AC 39 ms
24,048 KB
testcase_04 AC 39 ms
23,304 KB
testcase_05 AC 39 ms
23,740 KB
testcase_06 AC 39 ms
23,628 KB
testcase_07 AC 38 ms
23,612 KB
testcase_08 AC 38 ms
23,832 KB
testcase_09 AC 38 ms
24,240 KB
testcase_10 AC 38 ms
23,580 KB
testcase_11 AC 37 ms
24,024 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# -*- coding: utf-8 -*-
"""
No.513 宝探し2
https://yukicoder.me/problems/no/513

"""
import sys
from sys import stdin
input = stdin.readline


def check_distance(x, y):
    print(x, y, flush=True)
    dist = int(input())
    return dist


def main(args):
    dist = check_distance(0, 0)
    lx = 0
    rx = dist

    lx_update = True
    rx_update = True

    while dist != 0:
        if lx_update:
            ldist = check_distance(lx, dist - lx)
            lx_update = False
            if ldist == 0:
                break
        if rx_update:
            rdist = check_distance(rx, dist - rx)
            rx_update = False
            if rdist == 0:
                break

        if ldist == rdist:
            lx = (lx + rx) // 2
            lx_update = True
        elif ldist < rdist:
            rx = (lx + rx) // 2
            rx_update = True
        else:
            lx = (lx + rx) // 2
            lx_update = True


if __name__ == '__main__':
    main(sys.argv[1:])
0