結果
| 問題 | No.594 壊れた宝物発見機 | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2017-11-10 22:48:11 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                TLE
                                 
                             | 
| 実行時間 | - | 
| コード長 | 2,238 bytes | 
| コンパイル時間 | 1,860 ms | 
| コンパイル使用メモリ | 167,272 KB | 
| 実行使用メモリ | 44,068 KB | 
| 最終ジャッジ日時 | 2024-07-16 15:28:42 | 
| 合計ジャッジ時間 | 8,328 ms | 
| ジャッジサーバーID (参考情報) | judge2 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | TLE * 1 -- * 19 | 
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:87:9: warning: 'minz' may be used uninitialized [-Wmaybe-uninitialized]
   87 |         if (minz == zinf) {
      |         ^~
main.cpp:59:13: note: 'minz' was declared here
   59 |         int minz;
      |             ^~~~
main.cpp:82:9: warning: 'miny' may be used uninitialized [-Wmaybe-uninitialized]
   82 |         if (miny == yinf) {
      |         ^~
main.cpp:58:13: note: 'miny' was declared here
   58 |         int miny;
      |             ^~~~
main.cpp:77:9: warning: 'minx' may be used uninitialized [-Wmaybe-uninitialized]
   77 |         if (minx == xinf) {
      |         ^~
main.cpp:57:13: note: 'minx' was declared here
   57 |         int minx;
      |             ^~~~
            
            ソースコード
#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;
        ll mini = INF<ll>;
        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;
                    const ll ans = ask(x, y, z);
                    if (ans < mini) {
                        mini = ans;
                        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 (miny == yinf) {
            yinf = (yinf + ysup) / 2;
        }
        if (minz == zinf) {
            zsup = (zinf + zsup) / 2;
        } else if (minz == zinf) {
            zinf = (zinf + zsup) / 2;
        }
    }
    cout << "! " << xinf << " " << yinf << " " << zinf << endl;
    return 0;
}
            
            
            
        