結果

問題 No.594 壊れた宝物発見機
ユーザー tnakao0123tnakao0123
提出日時 2017-11-13 11:51:15
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,390 bytes
コンパイル時間 1,868 ms
コンパイル使用メモリ 82,576 KB
実行使用メモリ 24,504 KB
平均クエリ数 73.00
最終ジャッジ日時 2023-09-23 15:06:10
合計ジャッジ時間 4,719 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 #

/* -*- 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