結果

問題 No.594 壊れた宝物発見機
ユーザー kosakkunkosakkun
提出日時 2017-11-10 23:22:00
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,978 bytes
コンパイル時間 921 ms
コンパイル使用メモリ 110,864 KB
実行使用メモリ 24,504 KB
平均クエリ数 34.00
最終ジャッジ日時 2023-09-23 14:53:51
合計ジャッジ時間 4,598 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 <iostream>
#include <fstream>
#include <sstream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <string.h>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
typedef long long ll;

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

void answer(int x, int y, int z) {
    cout << "!" << " " << x << " " << y << " " << z << endl;
}

int main(void) {
    
    bool dir1 = true;
    bool dir2 = true;
    bool dir3 = true;
    int O  = ask(0, 0, 0);
    int Ox = ask(1, 0, 0);
    int Oy = ask(0, 1, 0);
    int Oz = ask(0, 0, 1);
    if (O < Ox) dir1 = false;
    if (O < Oy) dir2 = false;
    if (O < Oz) dir3 = false;
    Ox = Oy = Oz = O;

    int si1 = dir1 ? 1 : -1;
    int x = 2 * si1;
    int nx = ask(x, 0, 0);
    while (Ox * si1 > nx * si1) {
        Ox = nx;
        x += 2 * si1;
    }

    int si2 = dir2 ? 1 : -1;
    int y = 2 * si2;
    int ny = ask(0, y, 0);
    while (Oy * si2 > ny * si2) {
        Oy = ny;
        y += 2 * si2;
    }

    int si3 = dir3 ? 1 : -1;
    int z = 2 * si3;
    int nz = ask(0, 0, z);
    while (Oz * si3 > nz * si3) {
        Oz = nz;
        z += 2 * si3;
    }

    for (int i = x - 1; i <= x + 1; i++) {
        for (int j = y - 1; j <= y + 1; j++) {
            for (int k = z - 1; k <= z + 1; k++) {
                int d = ask(i, j, k);
                if (d == 0) {
                    answer(i, j, k);
                    return 0;
                }
            }
        }
    }

    return 0;
}
0