結果

問題 No.594 壊れた宝物発見機
ユーザー finefine
提出日時 2017-11-10 23:17:17
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,906 bytes
コンパイル時間 1,608 ms
コンパイル使用メモリ 168,848 KB
実行使用メモリ 24,432 KB
平均クエリ数 124.60
最終ジャッジ日時 2023-09-23 14:52:25
合計ジャッジ時間 4,950 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 106 ms
23,940 KB
testcase_01 AC 102 ms
23,448 KB
testcase_02 WA -
testcase_03 AC 101 ms
23,400 KB
testcase_04 WA -
testcase_05 AC 101 ms
23,580 KB
testcase_06 AC 108 ms
23,412 KB
testcase_07 AC 108 ms
23,568 KB
testcase_08 AC 112 ms
23,484 KB
testcase_09 AC 111 ms
23,460 KB
testcase_10 AC 105 ms
24,312 KB
testcase_11 AC 107 ms
24,360 KB
testcase_12 AC 104 ms
23,316 KB
testcase_13 AC 100 ms
23,580 KB
testcase_14 AC 107 ms
23,316 KB
testcase_15 AC 109 ms
24,312 KB
testcase_16 AC 95 ms
23,352 KB
testcase_17 AC 99 ms
23,316 KB
testcase_18 AC 99 ms
23,328 KB
testcase_19 AC 99 ms
23,436 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: 関数 ‘int main()’ 内:
main.cpp:82:11: 警告: ‘ap.Point::z’ may be used uninitialized [-Wmaybe-uninitialized]
   82 |     answer(ap.x, ap.y, ap.z);
      |     ~~~~~~^~~~~~~~~~~~~~~~~~
main.cpp:54:11: 備考: ‘ap.Point::z’ はここで定義されています
   54 |     Point ap;
      |           ^~
main.cpp:82:11: 警告: ‘ap.Point::y’ may be used uninitialized [-Wmaybe-uninitialized]
   82 |     answer(ap.x, ap.y, ap.z);
      |     ~~~~~~^~~~~~~~~~~~~~~~~~
main.cpp:54:11: 備考: ‘ap.Point::y’ はここで定義されています
   54 |     Point ap;
      |           ^~
main.cpp:82:11: 警告: ‘ap.Point::x’ may be used uninitialized [-Wmaybe-uninitialized]
   82 |     answer(ap.x, ap.y, ap.z);
      |     ~~~~~~^~~~~~~~~~~~~~~~~~
main.cpp:54:11: 備考: ‘ap.Point::x’ はここで定義されています
   54 |     Point ap;
      |           ^~

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

using ll = long long;

int ax = -25, ay = 25, az = 35;

// 質問クエリ
int ask(int x, int y, int z) {
	int d;
	cout << "?" << " " << x << " " << y << " " << z << endl;
    cin >> d;
	return d;//(ax - x) * (ax - x) + (ay - y) * (ay - y) + (az - z) * (az - z);
}

// 回答クエリ
void answer(int x, int y, int z) {
	cout << "!" << " " << x << " " << y << " " << z << endl;
}

struct Point {
    int x;
    int y;
    int z;
};

bool judge(vector<Point>& v) {
    return v[1].x - v[0].x > 1 || v[2].y - v[0].y > 1 || v[4].z - v[0].z > 0;
}

int mid(int x, int y) {
    int sum = x + y;
    if (sum < 0) return (sum - 1) / 2;
    else return (sum + 1) / 2;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    vector<Point> v;
    for (int i = 0; i < 8; i++) {
        int x, y, z;
        if (i & 1) x = 100;
        else x = -100;
        if (i & 2) y = 100;
        else y = -100;
        if (i & 4) z = 100;
        else z = -100;
        v.push_back((Point){x, y, z});
    }
    int idx = -1, vmax = 1145141919;
    int cnt = 0;
    Point ap;
    while (judge(v) && cnt < 192) {
        vector<int> ans(8);
        for (int i = 0; i < 8; i++) {
            ans[i] = ask(v[i].x, v[i].y, v[i].z);
            cnt++;
        }
        int ti = 0;
        for (int i = 1; i < 8; i++) {
            if (ans[i] < ans[ti]) {
                ti = i;
            }
        }
        idx = ti;
        if (ans[idx] < vmax) {
            vmax = ans[idx];
            ap.x = v[idx].x;
            ap.y = v[idx].y;
            ap.z = v[idx].z;
        }
        Point p = v[idx];
        for (int i = 0; i < 8; i++) {
            if (idx == i) continue;
            v[i].x = mid(v[i].x, v[idx].x);
            v[i].y = mid(v[i].y, v[idx].y);
            v[i].z = mid(v[i].z, v[idx].z);
        }
    }
    answer(ap.x, ap.y, ap.z);
    return 0;
}
0