結果

問題 No.594 壊れた宝物発見機
ユーザー cormorancormoran
提出日時 2017-11-10 23:23:04
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 110 ms / 2,000 ms
コード長 2,162 bytes
コンパイル時間 2,952 ms
コンパイル使用メモリ 165,140 KB
実行使用メモリ 24,384 KB
平均クエリ数 82.20
最終ジャッジ日時 2023-09-23 14:54:28
合計ジャッジ時間 5,410 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 109 ms
23,388 KB
testcase_01 AC 108 ms
24,012 KB
testcase_02 AC 110 ms
24,036 KB
testcase_03 AC 107 ms
23,964 KB
testcase_04 AC 107 ms
23,832 KB
testcase_05 AC 106 ms
23,652 KB
testcase_06 AC 107 ms
23,892 KB
testcase_07 AC 109 ms
24,360 KB
testcase_08 AC 106 ms
23,976 KB
testcase_09 AC 108 ms
24,384 KB
testcase_10 AC 109 ms
24,264 KB
testcase_11 AC 106 ms
23,376 KB
testcase_12 AC 108 ms
23,808 KB
testcase_13 AC 105 ms
23,604 KB
testcase_14 AC 107 ms
24,360 KB
testcase_15 AC 109 ms
24,300 KB
testcase_16 AC 106 ms
24,024 KB
testcase_17 AC 107 ms
24,012 KB
testcase_18 AC 106 ms
24,024 KB
testcase_19 AC 110 ms
24,336 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

using pii = pair<int,int>;
using ll = long long;
#define rep(i, j) for(int i=0; i < (int)(j); i++)
#define repeat(i, j, k) for(int i = (j); i < (int)(k); i++)
#define all(v) v.begin(),v.end()
#define debug(x) cerr << #x << " : " << x << endl

template<class T> bool set_min(T &a, const T &b) { return a > b  ? a = b, true : false; }
template<class T> bool set_max(T &a, const T &b) { return a < b  ? a = b, true : false; }
// vector
template<class T> istream& operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; }
template<class T> ostream& operator << (ostream &os , const vector<T> &v) { for(const T &t : v) os << "\t" << t; return os << endl; }
// pair
template<class T, class U> ostream& operator << (ostream &os , const pair<T, U> &v) { return os << "<" << v.first << ", " << v.second << ">"; }

const int INF = 1 << 30;
const ll INFL = 1LL << 60;


class Solver {
  public:    
    int ask(int x, int y, int z) {
        int d;
        cout << "?" << " " << x << " " << y << " " << z << endl;
        cin >> d;        
        return d;
    }
    void answer(int x, int y, int z) {
        cout << "!" << " " << x << " " << y << " " << z << endl;
    }
    void search(int &a, int &b, int &c, int &t) {
        int l = -150, r = 150 + 1;
        while(l + 2 < r) {
            int m1 = l + (r - l) / 3;
            int m2 = l + (r - l) * 2 / 3;
            t = m1;
            int d1 = ask(a, b, c);
            t = m2;
            int d2 = ask(a, b, c);
            if(d1 >= d2) l = m1;
            else r = m2;
            cerr << l << " " << r << endl;
        }
        t = l;
        int mn = l;
        int d = ask(a, b, c);
        while(++l < r) {
            t = l;
            if(set_min(d, ask(a, b, c))) {
                mn = l;
            }
        }
        t = mn;
    }
    bool solve() {
        int x = 0, y = 0, z = 0;
        search(x, y, z, x);
        search(x, y, z, y);
        search(x, y, z, z);
        answer(x, y, z);
        return 0;
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    Solver s;
    s.solve();
    return 0;
}
0