結果

問題 No.594 壊れた宝物発見機
ユーザー PachicobuePachicobue
提出日時 2017-11-10 22:39:09
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 2,161 bytes
コンパイル時間 1,470 ms
コンパイル使用メモリ 165,240 KB
実行使用メモリ 43,756 KB
最終ジャッジ日時 2023-09-23 15:42:40
合計ジャッジ時間 7,943 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: 関数 ‘int main()’ 内:
main.cpp:85:9: 警告: ‘minz’ may be used uninitialized [-Wmaybe-uninitialized]
   85 |         if (minz == zinf) {
      |         ^~
main.cpp:59:13: 備考: ‘minz’ はここで定義されています
   59 |         int minz;
      |             ^~~~
main.cpp:80:9: 警告: ‘miny’ may be used uninitialized [-Wmaybe-uninitialized]
   80 |         if (miny == yinf) {
      |         ^~
main.cpp:58:13: 備考: ‘miny’ はここで定義されています
   58 |         int miny;
      |             ^~~~
main.cpp:75:9: 警告: ‘minx’ may be used uninitialized [-Wmaybe-uninitialized]
   75 |         if (minx == xinf) {
      |         ^~
main.cpp:57:13: 備考: ‘minx’ はここで定義されています
   57 |         int minx;
      |             ^~~~

ソースコード

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 ask(const int x, const int y, const int z)
{
    cout << "? " << x << " " << y << " " << z << endl;
    ll i;
    cin >> i;
    return i;
}

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

    int xinf = -100;
    int xsup = 100;
    int yinf = -100;
    int ysup = 100;
    int zinf = -100;
    int zsup = 100;

    while (true) {
        if (xinf == xsup and yinf == ysup and zinf == zsup) {
            break;
        }
        int minx;
        int miny;
        int minz;
        int mini = 10000;
        for (int i = 0; i < 2; i++) {
            const int x = (i == 0) ? xinf : xsup;
            for (int j = 0; j < 2; j++) {
                const int y = (i == 0) ? yinf : ysup;
                for (int k = 0; k < 2; k++) {
                    const int z = (i == 0) ? zinf : zsup;
                    if (ask(x, y, z) < mini) {
                        minx = x;
                        miny = y;
                        minz = z;
                    }
                }
            }
        }
        if (minx == xinf) {
            xsup = (xinf + xsup) / 2;
        } else if (minx == xinf) {
            xinf = (xinf + xsup) / 2;
        }
        if (miny == yinf) {
            ysup = (yinf + ysup) / 2;
        } else if (minx == xinf) {
            yinf = (yinf + ysup) / 2;
        }
        if (minz == zinf) {
            zsup = (zinf + zsup) / 2;
        } else if (minx == xinf) {
            zinf = (zinf + zsup) / 2;
        }
    }
    cout << "! " << xinf << " " << yinf << " " << zinf << endl;

    return 0;
}
0