結果

問題 No.594 壊れた宝物発見機
ユーザー K UK U
提出日時 2023-11-05 00:59:53
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 110 ms / 2,000 ms
コード長 2,727 bytes
コンパイル時間 1,903 ms
コンパイル使用メモリ 202,732 KB
実行使用メモリ 24,660 KB
平均クエリ数 51.00
最終ジャッジ日時 2023-11-05 01:00:01
合計ジャッジ時間 5,970 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 102 ms
24,660 KB
testcase_01 AC 101 ms
24,660 KB
testcase_02 AC 103 ms
24,660 KB
testcase_03 AC 104 ms
24,660 KB
testcase_04 AC 101 ms
24,660 KB
testcase_05 AC 100 ms
24,660 KB
testcase_06 AC 99 ms
24,660 KB
testcase_07 AC 110 ms
24,660 KB
testcase_08 AC 98 ms
24,660 KB
testcase_09 AC 100 ms
24,660 KB
testcase_10 AC 98 ms
24,660 KB
testcase_11 AC 102 ms
24,660 KB
testcase_12 AC 99 ms
24,660 KB
testcase_13 AC 103 ms
24,660 KB
testcase_14 AC 100 ms
24,660 KB
testcase_15 AC 101 ms
24,660 KB
testcase_16 AC 107 ms
24,660 KB
testcase_17 AC 102 ms
24,660 KB
testcase_18 AC 103 ms
24,660 KB
testcase_19 AC 105 ms
24,660 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
// #include <atcoder/all>
// using namespace atcoder;
#ifdef LOCAL
#include <debug.h>
#define dbg(...) debug::dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define dbg(...) void(0)
#endif
using namespace std;

// #define int long long

#define rep(i, a, b) for(int i=static_cast<int>(a), i##_end__=static_cast<int>(b); i < i##_end__; i++)
#define rep_r(i, a, b) for(int i=static_cast<int>(a), i##_end__=static_cast<int>(b); i >= i##_end__; i--)
#define fore(i, a) for(auto& i: a)
#define all(x) std::begin(x), std::end(x)

using ll = long long; // __int128;
using ull = unsigned long long;

template<class C> int siz(const C& c) { return static_cast<int>(c.size()); }
template<class T, size_t N> constexpr int siz(const T (&)[N]) { return static_cast<int>(N); }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> constexpr T pow2(T x){ return x * x; }
template<class T, class S> constexpr T divceil(T x, S div) { return (x % div == 0) ? x / div : (x >= 0) ? (x / div) + 1 : -((-x) / div); }
template<class T, class S> constexpr T divfloor(T x, S div){ return (x % div == 0) ? x / div : (x >= 0) ? (x / div) : -((-x) / div) - 1; }
constexpr long long INF = 1LL << 60; // 1.15e18
constexpr int MOD = (int)1e9 + 7;

// 整数の三分探索を二分探索で実現
// 凸型関数で結果が最大となるIndexを探索。同じ値が複数ある場合は、一番左のIndexを返す
// f(x) > f(x-1) となる最大のxを探索
// ※てっぺんの右側と左側の両方に平らな部分があるとうまく行かないことに注意
template<class T, class F>
T find_maximal(T l, T r, F f) {
    while(r - l > 1){
        auto m = (l + r) / 2;
        (f(m) > f(m - 1) ? l : r) = m;
    }
    return l;
}
template<class T, class F>
T find_minimal(T l, T r, F f) {
    while(r - l > 1){
        auto m = (l + r) / 2;
        (f(m) < f(m - 1) ? l : r) = m;
    }
    return l;
}

void _main() {
    int x = 0, y = 0, z = 0;

    int cord = 0;
    auto func = [&](int v){
        int x2 = cord == 0 ? v : x, y2 = cord == 1 ? v : y, z2 = cord == 2 ? v : z;
        cout << "? " << x2 << " " << y2 << " " << z2 << endl;
        int D;
        cin >> D;
        return D;
    };

    cord = 0;
    x = find_minimal(-150, 150, func);
    cord = 1;
    y = find_minimal(-150, 150, func);
    cord = 2;
    z = find_minimal(-150, 150, func);

    cout << "! " << x << " " << y << " " << z << endl;
}

signed main() { 
    cin.tie(nullptr); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15); cerr << fixed << setprecision(15);
    _main();
}
0