結果

問題 No.594 壊れた宝物発見機
コンテスト
ユーザー tnakao0123
提出日時 2017-11-13 12:00:33
言語 C++11
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=gnu++11 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 1,390 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 528 ms
コンパイル使用メモリ 103,084 KB
実行使用メモリ 28,976 KB
平均クエリ数 73.00
最終ジャッジ日時 2026-03-31 02:58:55
合計ジャッジ時間 3,109 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other WA * 20
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

/* -*- coding: utf-8 -*-
 *
 * 594.cc: No.594 壊れた宝物発見機 - yukicoder
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 100;
const int MIN_X = -150, MIN_Y = -150, MIN_Z = -150;
const int MAX_X =  150, MAX_Y =  150, MAX_Z =  150;
const int INF = 1 << 30;

/* typedef */

/* global variables */

/* subroutines */

/* main */

int main() {
  int x0 = MIN_X, y0 = MIN_Y, z0 = MIN_Z;
  int x1 = MAX_X + 1, y1 = MAX_Y + 1, z1 = MAX_Z + 1;

  while (x0 + 1 < x1) {
    int mind = INF, mini = -1;
    for (int i = 0; i < 8; i++) {
      int x = (i & 1) ? x1 : x0;
      int y = (i & 2) ? y1 : y0;
      int z = (i & 4) ? z1 : z0;

      printf("? %d %d %d\n", x, y, z); fflush(stdout);

      int d;
      scanf("%d", &d);
      if (mind > d) mind = d, mini = i;
    }

    int hx = (x0 + x1) / 2;
    int hy = (y0 + y1) / 2;
    int hz = (z0 + z1) / 2;
    if (mini & 1) x0 = hx;
    else x1 = hx;
    if (mini & 2) y0 = hy;
    else y1 = hy;
    if (mini & 4) z0 = hz;
    else z1 = hz;
  }

  printf("! %d %d %d\n", x1, y1, z1); fflush(stdout);

  return 0;
}
0