結果

問題 No.594 壊れた宝物発見機
ユーザー te-shte-sh
提出日時 2017-11-10 23:20:26
言語 D
(dmd 2.106.1)
結果
WA  
実行時間 -
コード長 1,195 bytes
コンパイル時間 2,577 ms
コンパイル使用メモリ 140,976 KB
実行使用メモリ 24,396 KB
平均クエリ数 52.10
最終ジャッジ日時 2023-09-03 16:49:55
合計ジャッジ時間 5,175 ms
ジャッジサーバーID
(参考情報)
judge11 / 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 AC 104 ms
24,240 KB
testcase_16 AC 109 ms
24,012 KB
testcase_17 AC 107 ms
24,024 KB
testcase_18 WA -
testcase_19 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import std.algorithm, std.conv, std.range, std.stdio, std.string;
import std.math;      // math functions

void main()
{
  int x, y, z;

  auto xmi = -100, xma = 100;
  for (;;) {
    auto d1 = ask(xmi, 0, 0);
    auto d2 = ask(xma, 0, 0);
    if (xma - xmi == 1) {
      if (d1 > d2)
        x = xma;
      else
        x = xmi;
      break;
    }
    if (d1 > d2)
      xmi = (xmi + xma) / 2;
    else
      xma = (xmi + xma) / 2;
  }

  auto ymi = -100, yma = 100;
  for (;;) {
    auto d1 = ask(0, ymi, 0);
    auto d2 = ask(0, yma, 0);
    if (yma - ymi == 1) {
      if (d1 > d2)
        y = yma;
      else
        y = ymi;
      break;
    }
    if (d1 > d2)
      ymi = (ymi + yma) / 2;
    else
      yma = (ymi + yma) / 2;
  }

  auto zmi = -100, zma = 100;
  for (;;) {
    auto d1 = ask(0, zmi, 0);
    auto d2 = ask(0, zma, 0);
    if (zma - zmi == 1) {
      if (d1 > d2)
        z = zma;
      else
        z = zmi;
      break;
    }
    if (d1 > d2)
      zmi = (zmi + zma) / 2;
    else
      zma = (zmi + zma) / 2;
  }

  writefln("! %d %d %d", x, y, z);
}

auto ask(int x, int y, int z)
{
  writefln("? %d %d %d", x, y, z);
  stdout.flush();
  return readln.chomp.to!int;
}
0