結果

問題 No.594 壊れた宝物発見機
ユーザー nebukuro09nebukuro09
提出日時 2017-11-10 22:46:19
言語 D
(dmd 2.106.1)
結果
RE  
実行時間 -
コード長 998 bytes
コンパイル時間 608 ms
コンパイル使用メモリ 100,024 KB
実行使用メモリ 24,408 KB
平均クエリ数 1.00
最終ジャッジ日時 2023-09-03 16:47:44
合計ジャッジ時間 4,725 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop;

long ask(int[] xyz) {
    writeln("? ", xyz[0], " ", xyz[1], " ", xyz[2]);
    stdout.flush;
    return readln.to!long;
}

int search(int xyz) {
    long[int] d;
    int[] query = [-150, -150, -150];
    foreach (i; iota(-100, 101, 10)) {
        query[xyz] = i;
        d[i] = ask(query);
    }

    int mi = -1;
    long md = 1L << 59;
    foreach (k; d.keys) {
        if (d[k] < md) {
            mi = k;
            md = d[k];
        }
    }

    int mmi = -1;
    long mmd = 1L << 59;
    foreach (i; iota(-15, 15)) {
        query[xyz] = mi + i;
        long dd = ask(query);
        if (dd < mmd) {
            mmi = mi + i;
            mmd = dd;
        }
    }

    return mmi;
}


void main() {
    int x = search(0);
    int y = search(1);
    int z = search(2);
    writeln("! ", x, " " , y , " ", z);
}
0