結果

問題 No.594 壊れた宝物発見機
ユーザー okayunonahaokayunonaha
提出日時 2017-11-11 00:11:09
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 109 ms / 2,000 ms
コード長 1,802 bytes
コンパイル時間 1,542 ms
コンパイル使用メモリ 165,368 KB
実行使用メモリ 24,480 KB
平均クエリ数 56.30
最終ジャッジ日時 2023-09-23 15:00:55
合計ジャッジ時間 5,037 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 108 ms
23,808 KB
testcase_01 AC 106 ms
24,324 KB
testcase_02 AC 105 ms
23,412 KB
testcase_03 AC 105 ms
23,532 KB
testcase_04 AC 107 ms
23,628 KB
testcase_05 AC 103 ms
23,640 KB
testcase_06 AC 104 ms
23,400 KB
testcase_07 AC 104 ms
23,628 KB
testcase_08 AC 104 ms
23,352 KB
testcase_09 AC 109 ms
24,312 KB
testcase_10 AC 107 ms
23,376 KB
testcase_11 AC 105 ms
24,036 KB
testcase_12 AC 106 ms
24,480 KB
testcase_13 AC 106 ms
23,820 KB
testcase_14 AC 105 ms
24,036 KB
testcase_15 AC 106 ms
23,364 KB
testcase_16 AC 104 ms
23,808 KB
testcase_17 AC 105 ms
23,808 KB
testcase_18 AC 105 ms
23,820 KB
testcase_19 AC 105 ms
23,976 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

using ll = long long;
//typedef long long ll;

#define INF (1LL << 31 - 1)
#define INFLL ((1LL << 62) - 1)
#define MOD int(1e9+7)
#define repi(i,j,n) for(int i = (j); i < (n); ++i)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) for (int i = n; i >= 0; --i)
#define fi first
#define se second
#define all(v) (v).begin(), (v).end()

int vx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, vy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};

inline bool check(int ux, int uy, int x, int y) {
  return (0 <= x and x < ux and 0 <= y and y < uy);
}

inline void init() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

int bx, ux, by, uy, bz, uz, x, y, z;
ll d, l, r;

inline void answer(int X, int Y, int Z) {
  cout << "!" << " " << X << " " << Y << " " << Z << endl;
}

inline ll query(int X, int Y, int Z) {
  ll ret;
  cout << "?" << " " << X << " " << Y << " " << Z << endl;
  cin >> ret;
  return ret;
}

int main() {
  init();
  bx = by = bz = -150;
  ux = uy = uz = 150;
  x = y = z = INF;

  while (ux - bx > 1) {
    l = query(bx, by, bz);
    r = query(ux, by, bz);

    if (l < r) {
      ux = (bx + ux) / 2;
    }
    else {
      bx = (bx + ux) / 2;
    }
  }

  l = query(bx, by, bz);
  r = query(ux, by, bz);

  if (l < r) x = bx;
  else x = ux;

  while (uy - by > 1) {
    l = query(x, by, bz);
    r = query(x, uy, bz);

    if (l < r) {
      uy = (by + uy) / 2;
    }
    else by = (by + uy) / 2;
  }

  l = query(x, by, bz);
  r = query(x, uy, bz);

  if (l < r) y = by;
  else y = uy;

  while (uz - bz > 1) {
    l = query(x, y, bz);
    r = query(x, y, uz);

    if (l < r) {
      uz = (bz + uz) / 2;
    }
    else bz = (bz + uz) / 2;
  }

  l = query(x, y, bz);
  r = query(x, y, uz);

  if (l < r) z = bz;
  else z = uz;

  answer(x, y, z);

  return 0;
}
0