結果

問題 No.513 宝探し2
ユーザー kichirb3
提出日時 2018-03-08 19:41:58
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 47 ms / 2,000 ms
コード長 988 bytes
コンパイル時間 104 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 27,608 KB
平均クエリ数 9.33
最終ジャッジ日時 2024-07-17 01:36:13
合計ジャッジ時間 1,492 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 12
権限があれば一括ダウンロードができます

ソースコード

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