結果

問題 No.594 壊れた宝物発見機
ユーザー GrayCoderGrayCoder
提出日時 2018-07-29 20:43:34
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 140 ms / 2,000 ms
コード長 1,073 bytes
コンパイル時間 141 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 27,608 KB
平均クエリ数 72.90
最終ジャッジ日時 2024-07-16 15:58:27
合計ジャッジ時間 4,254 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

from sys import stdin, stdout
input = lambda: stdin.readline().rstrip()
write = stdout.write

def main():
    x = y = z = 0
    for s in ('x', 'y', 'z'):
        d = dist(s, x, y, z)
        if s == 'x':
            x = d
        elif s == 'y':
            y = d
        else:
            z = d
    print('!', x, y, z)
    stdout.flush()

def dist(axis, x, y, z):
    point = -100
    max_ = 150
    dmin = float('inf')
    while point < max_:
        xi = point if axis == 'x' else x
        yi = point if axis == 'y' else y
        zi = point if axis == 'z' else z
        print('?', xi, yi, zi)
        stdout.flush()
        d = int(input())
        if d > dmin:
            break
        dmin = d
        point += 10
    dmin = d

    while 1:
        point -= 1
        xi = point if axis == 'x' else x
        yi = point if axis == 'y' else y
        zi = point if axis == 'z' else z
        print('?', xi, yi, zi)
        stdout.flush()
        d = int(input())
        if d < dmin:
            dmin = d
        else:
            break
    return point + 1

main()
0