結果

問題 No.594 壊れた宝物発見機
ユーザー tkmst201tkmst201
提出日時 2021-02-19 10:05:58
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 113 ms / 2,000 ms
コード長 1,456 bytes
コンパイル時間 2,142 ms
コンパイル使用メモリ 199,040 KB
実行使用メモリ 24,456 KB
平均クエリ数 73.60
最終ジャッジ日時 2023-09-24 09:47:24
合計ジャッジ時間 6,274 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 113 ms
24,012 KB
testcase_01 AC 108 ms
24,060 KB
testcase_02 AC 107 ms
23,988 KB
testcase_03 AC 107 ms
24,456 KB
testcase_04 AC 108 ms
23,664 KB
testcase_05 AC 107 ms
23,532 KB
testcase_06 AC 109 ms
23,364 KB
testcase_07 AC 108 ms
23,376 KB
testcase_08 AC 106 ms
24,000 KB
testcase_09 AC 106 ms
23,832 KB
testcase_10 AC 108 ms
23,952 KB
testcase_11 AC 109 ms
23,244 KB
testcase_12 AC 108 ms
24,252 KB
testcase_13 AC 108 ms
23,832 KB
testcase_14 AC 109 ms
23,544 KB
testcase_15 AC 108 ms
24,324 KB
testcase_16 AC 108 ms
24,024 KB
testcase_17 AC 109 ms
24,048 KB
testcase_18 AC 108 ms
16,312 KB
testcase_19 AC 108 ms
23,832 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
template<typename A, typename B> inline bool chmax(A & a, const B & b) { if (a < b) { a = b; return true; } return false; }
template<typename A, typename B> inline bool chmin(A & a, const B & b) { if (a > b) { a = b; return true; } return false; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = false;
//---------------------------------//

int main() {
	auto query = [](int X, int Y, int Z) -> int {
		printf("? %d %d %d\n", X, Y, Z);
		fflush(stdout);
		int D;
		scanf("%d", &D);
		if (D == -1) assert(false);
		return D;
	};
	
	int l[3] {}, r[3] {};
	REP(i, 3) {
		l[i] = -103;
		r[i] = 103;
		int lv = INF, rv = INF;
		auto q = [&](int x) {
			int arg[3];
			REP(j, 3) arg[j] = i == j ? x : l[j];
			return query(arg[0], arg[1], arg[2]);
		};
		while (r[i] - l[i] > 2) {
			const int m1 = (2 * l[i] + r[i]) / 3, m2 = (l[i] + 2 * r[i]) / 3;
			const int y1 = q(m1), y2 = q(m2);
			if (y1 < y2) r[i] = m2, rv = y2;
			else l[i] = m1, lv = y1;
		}
		if (r[i] - l[i] == 1 && lv > rv) swap(l[i], r[i]);
		else {
			int m = (l[i] + r[i]) / 2;
			int y = q(m);
			if (y > lv) m = l[i], y = lv;
			if (y > rv) m = r[i], y = rv;
			l[i] = m;
		}
	}
	
	printf("! %d %d %d\n", l[0], l[1], l[2]);
}
0