結果

問題 No.594 壊れた宝物発見機
ユーザー nanaenanae
提出日時 2017-11-10 23:27:46
言語 D
(dmd 2.105.2)
結果
AC  
実行時間 110 ms / 2,000 ms
コード長 1,725 bytes
コンパイル時間 1,499 ms
コンパイル使用メモリ 145,512 KB
実行使用メモリ 24,324 KB
平均クエリ数 47.20
最終ジャッジ日時 2023-09-03 16:50:24
合計ジャッジ時間 5,077 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 110 ms
24,180 KB
testcase_01 AC 105 ms
23,424 KB
testcase_02 AC 108 ms
23,412 KB
testcase_03 AC 108 ms
23,664 KB
testcase_04 AC 107 ms
24,048 KB
testcase_05 AC 108 ms
23,640 KB
testcase_06 AC 108 ms
23,820 KB
testcase_07 AC 108 ms
23,412 KB
testcase_08 AC 107 ms
23,544 KB
testcase_09 AC 108 ms
24,000 KB
testcase_10 AC 108 ms
24,324 KB
testcase_11 AC 107 ms
23,820 KB
testcase_12 AC 109 ms
24,060 KB
testcase_13 AC 108 ms
23,652 KB
testcase_14 AC 108 ms
23,640 KB
testcase_15 AC 107 ms
23,964 KB
testcase_16 AC 107 ms
23,544 KB
testcase_17 AC 108 ms
23,424 KB
testcase_18 AC 107 ms
23,556 KB
testcase_19 AC 108 ms
23,424 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

void main() {
    int query(int x, int y, int z) {
        int d;
        writefln("? %d %d %d", x, y, z);
        stdout.flush();
        scan(d);
        return d;
    }

    int ansx, ansy, ansz;

    int top = 105, btm = -105;

    while (top - btm > 1) {
        int mid = (btm + top) / 2;

        int d1 = query(mid, 0, 0);
        int d2 = query(mid + 1, 0, 0);

        if (d2 - d1 > 0) {
            top = mid;
        }
        else {
            btm = mid;
        }
    }

    ansx = top;

    top = 105, btm = -105;

    while (top - btm > 1) {
        int mid = (btm + top) / 2;

        int d1 = query(0, mid, 0);
        int d2 = query(0, mid + 1, 0);

        if (d2 - d1 > 0) {
            top = mid;
        }
        else {
            btm = mid;
        }
    }

    ansy = top;

    top = 105, btm = -105;

    while (top - btm > 1) {
        int mid = (btm + top) / 2;

        int d1 = query(0, 0, mid);
        int d2 = query(0, 0, mid + 1);

        if (d2 - d1 > 0) {
            top = mid;
        }
        else {
            btm = mid;
        }
    }

    ansz = top;

    writefln("! %d %d %d", ansx, ansy, ansz);
    stdout.flush();
}






void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}
0