結果

問題 No.594 壊れた宝物発見機
ユーザー rpy3cpprpy3cpp
提出日時 2017-11-13 00:11:39
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,406 bytes
コンパイル時間 1,734 ms
コンパイル使用メモリ 164,800 KB
実行使用メモリ 24,420 KB
平均クエリ数 257.00
最終ジャッジ日時 2023-09-23 15:05:52
合計ジャッジ時間 5,725 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int ask(int x, int y, int z){
    cout << "? " << x << ' ' << y << ' ' << z << endl;
    int d;
    cin >> d;
    return d;
}

int fix_x(int xa, int xb, int y, int z){
    while (xa < xb){
        int x1 = xa + (xb - xa)/3;
        int x2 = xa + 2 * (xb - xa)/3;
        int d1 = ask(x1, y, z);
        int d2 = ask(x2, y, z);
        if (d1 > d2){
            xa = x1;
        }else{
            xb = x2;
        }
    }
    return xa;
}

int fix_y(int x, int ya, int yb, int z){
    while (ya < yb){
        int y1 = ya + (yb - ya)/3;
        int y2 = ya + 2 * (yb - ya)/3;
        int d1 = ask(x, y1, z);
        int d2 = ask(x, y2, z);
        if (d1 > d2){
            ya = y1;
        }else{
            yb = y2;
        }
    }
    return ya;
}

int fix_z(int x, int y, int za, int zb){
    while (za < zb){
        int z1 = za + (zb - za)/3;
        int z2 = za + 2 * (zb - za)/3;
        int d1 = ask(x, y, z1);
        int d2 = ask(x, y, z2);
        if (d1 > d2){
            za = z1;
        }else{
            zb = z2;
        }
    }
    return za;
}

int main(){
    int xa = -150;
    int xb = 150;
    int ya = -150;
    int yb = 150;
    int za = -150;
    int zb = 150;
    int x = fix_x(xa, xb, 0, 0);
    int y = fix_y(x, ya, yb, 0);
    int z = fix_z(x, y, za, zb);
    cout << "! " << x << ' ' << y << ' ' << z << endl;
    return 0;
}
0