結果

問題 No.513 宝探し2
コンテスト
ユーザー te-sh
提出日時 2017-05-05 22:54:38
言語 D
(dmd 2.112.0)
コンパイル:
dmd -fPIE -m64 -w -wi -O -release -inline -I/opt/dmd/src/druntime/import/ -I/opt/dmd/src/phobos -L-L/opt/dmd/linux/lib64/ -fPIC _filename_
実行:
./Main
結果
RE  
実行時間 -
コード長 1,148 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 677 ms
コンパイル使用メモリ 79,648 KB
実行使用メモリ 28,976 KB
平均クエリ数 76.17
最終ジャッジ日時 2026-03-05 14:30:20
合計ジャッジ時間 1,944 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other RE * 12
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import std.algorithm, std.conv, std.range, std.stdio, std.string;

void main()
{
  auto ans = int.max;
  auto x = 50000, y = 50000;
  auto xi = 0, xa = 100000, yi = 0, ya = 100000;

  for (;;) {
    writeln(xi, " ", y); stdout.flush();
    auto ri = readln.chomp.to!int;

    writeln(xa, " ", y); stdout.flush();
    auto ra = readln.chomp.to!int;

    writeln(x, " ", y); stdout.flush();
    auto r = readln.chomp.to!int;
    
    if (xa - xi <= 2) {
      if (x <= xa && x <= xi) {
        break;
      } else if (xi <= x && xi <= xa) {
        x = xi;
        break;
      } else {
        x = xa;
        break;
      }
    } else {
      if (xi >= xa) {
        xi = x;
        x = (xa - xi) / 2;
      } else {
        xa = x;
        x = (xa - xi) / 2;
      }
    }
  }
    
  for (;;) {
    writeln(x, " ", yi); stdout.flush();
    auto ri = readln.chomp.to!int;

    writeln(x, " ", ya); stdout.flush();
    auto ra = readln.chomp.to!int;

    writeln(x, " ", y); stdout.flush();
    auto r = readln.chomp.to!int;

    if (yi >= ya) {
      yi = y;
      y = (ya - yi) / 2;
    } else {
      ya = y;
      y = (ya - yi) / 2;
    }
  }
}
0