結果

問題 No.594 壊れた宝物発見機
ユーザー xuzijian629xuzijian629
提出日時 2018-10-30 00:57:55
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 107 ms / 2,000 ms
コード長 1,448 bytes
コンパイル時間 2,541 ms
コンパイル使用メモリ 208,428 KB
実行使用メモリ 24,372 KB
平均クエリ数 77.80
最終ジャッジ日時 2023-09-23 16:29:52
合計ジャッジ時間 6,608 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 104 ms
23,568 KB
testcase_01 AC 98 ms
23,340 KB
testcase_02 AC 103 ms
23,424 KB
testcase_03 AC 106 ms
24,336 KB
testcase_04 AC 98 ms
23,640 KB
testcase_05 AC 98 ms
23,616 KB
testcase_06 AC 107 ms
23,328 KB
testcase_07 AC 101 ms
23,388 KB
testcase_08 AC 101 ms
23,604 KB
testcase_09 AC 99 ms
24,000 KB
testcase_10 AC 100 ms
23,976 KB
testcase_11 AC 98 ms
24,024 KB
testcase_12 AC 98 ms
24,372 KB
testcase_13 AC 100 ms
24,000 KB
testcase_14 AC 101 ms
24,288 KB
testcase_15 AC 104 ms
23,640 KB
testcase_16 AC 105 ms
24,024 KB
testcase_17 AC 103 ms
23,988 KB
testcase_18 AC 98 ms
24,120 KB
testcase_19 AC 96 ms
23,388 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using vi = vector<i64>;
using vvi = vector<vi>;

vi ls(3, -100), rs(3, 100);
vi g(3);

void ask(int x, int y, int z) {
    cout << "? " << x << " " << y << " " << z << endl;
}

void ask(vi v) {
    ask(v[0], v[1], v[2]);
}

void ans(int x, int y, int z) {
    cout << "! " << x << " " << y << " " << z << endl;
    exit(0);
}

int get() {
    int d;
    cin >> d;
    if (d == -1) exit(1);
    return d;
}

vi make_coord(int x, int i) {
    vi ret(3);
    for (int j = 0; j < 3; j++) {
        if (j == i) {
            ret[i] = x;
        } else {
            ret[j] = ls[j];
        }
    }
    return ret;
}

void solve(int i) {
    int l = ls[i], r = rs[i];
    while (l < r - 3) {
        int ml = l + (r - l) / 3;
        int mr = l + (r - l) * 2 / 3;
        vi vl = make_coord(ml, i);
        vi vr = make_coord(mr, i);
        ask(vl);
        int dl = get();
        ask(vr);
        int dr = get();
        if (dl < dr) {
            r = mr;
        } else {
            l = ml;
        }
    }
    using ii = pair<int, int>; // dist, x
    vector<ii> res;
    for (int j = l; j <= r; j++) {
        vi v = make_coord(j, i);
        ask(v);
        int d = get();
        res.push_back(ii(d, j));
    }
    sort(res.begin(), res.end());
    g[i] = res.front().second;
}

int main() {
    for (int i = 0; i < 3; i++) {
        solve(i);
    }
    ans(g[0], g[1], g[2]);
}
0