結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
権限があれば一括ダウンロードができます

ソースコード

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] = -102;
		r[i] = 102;
		int lv = -1, rv = -1;
		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) {
			printf("l = %d r = %d\n", l[i], r[i]);
			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