結果

問題 No.594 壊れた宝物発見機
ユーザー PachicobuePachicobue
提出日時 2017-11-10 23:24:21
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 108 ms / 2,000 ms
コード長 2,279 bytes
コンパイル時間 1,345 ms
コンパイル使用メモリ 166,712 KB
実行使用メモリ 24,324 KB
平均クエリ数 47.80
最終ジャッジ日時 2023-09-23 14:54:33
合計ジャッジ時間 4,573 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 101 ms
24,324 KB
testcase_01 AC 93 ms
23,604 KB
testcase_02 AC 97 ms
24,060 KB
testcase_03 AC 96 ms
23,976 KB
testcase_04 AC 108 ms
24,324 KB
testcase_05 AC 96 ms
23,796 KB
testcase_06 AC 96 ms
23,616 KB
testcase_07 AC 96 ms
23,532 KB
testcase_08 AC 93 ms
23,412 KB
testcase_09 AC 94 ms
23,976 KB
testcase_10 AC 94 ms
23,988 KB
testcase_11 AC 95 ms
23,664 KB
testcase_12 AC 104 ms
23,532 KB
testcase_13 AC 101 ms
23,640 KB
testcase_14 AC 97 ms
24,264 KB
testcase_15 AC 92 ms
23,628 KB
testcase_16 AC 94 ms
23,688 KB
testcase_17 AC 94 ms
23,268 KB
testcase_18 AC 92 ms
23,820 KB
testcase_19 AC 94 ms
23,736 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

#define show(x) cerr << #x << " = " << x << endl

using namespace std;
using ll = long long;

template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v)
{
    os << "sz:" << v.size() << "\n[";
    for (const auto& p : v) {
        os << p << ",";
    }
    os << "]\n";
    return os;
}

template <typename S, typename T>
ostream& operator<<(ostream& os, const pair<S, T>& p)
{
    os << "(" << p.first << "," << p.second
       << ")";
    return os;
}


constexpr ll MOD = (ll)1e9 + 7LL;

template <typename T>
constexpr T INF = numeric_limits<T>::max() / 64;

ll ans[3];
ll ask(const int x, const int y, const int z)
{
    static int q = 0;
    q++;
    if (q == 201) {
        cerr << "feuwfhiwf" << endl;
    }
    cout << "? " << x << " " << y << " " << z << endl;
    ll i;
    cin >> i;

    // i = (ans[0] - x) * (ans[0] - x) + (ans[1] - y) * (ans[1] - y) + (ans[2] - z) * (ans[2] - z);
    // show(i);
    return i;
}

int main()
{

    // mt19937 mt{random_device{}()};
    // uniform_int_distribution<ll> dist{-100, 100};
    // for (int i = 0; i < 3; i++) {
    //     ans[i] = dist(mt);
    // }

    vector<ll> sup(3, 150);
    vector<ll> inf(3, -150);
    for (int i = 0; i < 3; i++) {
        while (inf[i] < sup[i]) {
            const ll ainf = (i == 0) ? ask(inf[i], 0, 0) : (i == 1) ? ask(0, inf[i], 0) : ask(0, 0, inf[i]);
            const ll asup = (i == 0) ? ask(sup[i], 0, 0) : (i == 1) ? ask(0, sup[i], 0) : ask(0, 0, sup[i]);
            if (asup == ainf) {
                inf[i] = (inf[i] + sup[i]) / 2;
                sup[i] = inf[i];
            } else if (asup < ainf) {
                if (inf[i] == (inf[i] + sup[i]) / 2) {
                    break;
                }
                inf[i] = (inf[i] + sup[i]) / 2;
            } else {
                if (sup[i] == (inf[i] + sup[i]) / 2) {
                    sup[i]--;
                    break;
                }
                sup[i] = (inf[i] + sup[i]) / 2;
            }
        }
    }
    cout << "!";
    for (int i = 0; i < 3; i++) {
        cout << " " << sup[i];
    }
    cout << endl;

    // for (int i = 0; i < 3; i++) {
    //     if (ans[i] != sup[i]) {
    //         cerr << "NO" << endl;
    //     }
    // }

    return 0;
}
0