結果

問題 No.594 壊れた宝物発見機
ユーザー MisterMister
提出日時 2020-08-01 23:30:30
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 110 ms / 2,000 ms
コード長 1,316 bytes
コンパイル時間 1,306 ms
コンパイル使用メモリ 77,340 KB
実行使用メモリ 24,264 KB
平均クエリ数 79.60
最終ジャッジ日時 2023-09-24 04:00:18
合計ジャッジ時間 4,465 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 110 ms
23,376 KB
testcase_01 AC 103 ms
24,000 KB
testcase_02 AC 106 ms
23,640 KB
testcase_03 AC 105 ms
23,664 KB
testcase_04 AC 104 ms
24,000 KB
testcase_05 AC 102 ms
23,448 KB
testcase_06 AC 103 ms
23,412 KB
testcase_07 AC 100 ms
23,628 KB
testcase_08 AC 102 ms
23,412 KB
testcase_09 AC 102 ms
23,676 KB
testcase_10 AC 103 ms
23,820 KB
testcase_11 AC 97 ms
23,820 KB
testcase_12 AC 97 ms
23,532 KB
testcase_13 AC 102 ms
24,252 KB
testcase_14 AC 101 ms
24,264 KB
testcase_15 AC 99 ms
24,000 KB
testcase_16 AC 99 ms
23,616 KB
testcase_17 AC 100 ms
24,240 KB
testcase_18 AC 103 ms
23,868 KB
testcase_19 AC 97 ms
23,856 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <vector>
#include <string>

using lint = long long;
constexpr lint INF = 1LL << 60;

lint query(const std::vector<int>& xs) {
    std::cout << "?";
    for (auto x : xs) std::cout << " " << x;
    std::cout << std::endl;

    lint d;
    std::cin >> d;
    return d;
}

void answer(const std::vector<int>& xs) {
    std::cout << "!";
    for (auto x : xs) std::cout << " " << x;
    std::cout << std::endl;
}

void solve() {
    std::vector<int> xs(3, 0);

    for (int i = 0; i < 3; ++i) {
        int lx = -100, rx = 100;
        auto ys = xs;

        while (rx - lx >= 3) {
            int llx = (lx * 2 + rx) / 3,
                rrx = (lx + rx * 2) / 3;

            ys[i] = llx;
            auto dl = query(ys);

            ys[i] = rrx;
            auto dr = query(ys);

            if (dl < dr) {
                rx = rrx;
            } else {
                lx = llx;
            }
        }

        auto dmax = INF;
        for (int x = lx; x <= rx; ++x) {
            ys[i] = x;
            auto d = query(ys);

            if (d < dmax) {
                xs[i] = x;
                dmax = d;
            }
        }
    }

    answer(xs);
}

int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);

    solve();

    return 0;
}
0