結果
問題 | No.594 壊れた宝物発見機 |
ユーザー |
|
提出日時 | 2017-11-10 23:27:46 |
言語 | D (dmd 2.109.1) |
結果 |
AC
|
実行時間 | 113 ms / 2,000 ms |
コード長 | 1,725 bytes |
コンパイル時間 | 2,008 ms |
コンパイル使用メモリ | 146,864 KB |
実行使用メモリ | 25,232 KB |
平均クエリ数 | 47.20 |
最終ジャッジ日時 | 2024-06-12 22:28:08 |
合計ジャッジ時間 | 5,263 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 20 |
ソースコード
import std.stdio, std.string, std.conv, std.algorithm, std.numeric; import std.range, std.array, std.math, std.typecons, std.container, core.bitop; void main() { int query(int x, int y, int z) { int d; writefln("? %d %d %d", x, y, z); stdout.flush(); scan(d); return d; } int ansx, ansy, ansz; int top = 105, btm = -105; while (top - btm > 1) { int mid = (btm + top) / 2; int d1 = query(mid, 0, 0); int d2 = query(mid + 1, 0, 0); if (d2 - d1 > 0) { top = mid; } else { btm = mid; } } ansx = top; top = 105, btm = -105; while (top - btm > 1) { int mid = (btm + top) / 2; int d1 = query(0, mid, 0); int d2 = query(0, mid + 1, 0); if (d2 - d1 > 0) { top = mid; } else { btm = mid; } } ansy = top; top = 105, btm = -105; while (top - btm > 1) { int mid = (btm + top) / 2; int d1 = query(0, 0, mid); int d2 = query(0, 0, mid + 1); if (d2 - d1 > 0) { top = mid; } else { btm = mid; } } ansz = top; writefln("! %d %d %d", ansx, ansy, ansz); stdout.flush(); } void scan(T...)(ref T args) { string[] line = readln.split; foreach (ref arg; args) { arg = line.front.to!(typeof(arg)); line.popFront(); } assert(line.empty); } void fillAll(R, T)(ref R arr, T value) { static if (is(typeof(arr[] = value))) { arr[] = value; } else { foreach (ref e; arr) { fillAll(e, value); } } }