結果

問題 No.594 壊れた宝物発見機
ユーザー tkmst201tkmst201
提出日時 2021-02-19 10:01:07
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 114 ms / 2,000 ms
コード長 1,454 bytes
コンパイル時間 2,009 ms
コンパイル使用メモリ 198,800 KB
実行使用メモリ 24,264 KB
平均クエリ数 73.90
最終ジャッジ日時 2023-09-24 09:47:17
合計ジャッジ時間 5,581 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 114 ms
23,520 KB
testcase_01 AC 108 ms
24,240 KB
testcase_02 AC 107 ms
23,412 KB
testcase_03 AC 104 ms
23,412 KB
testcase_04 AC 104 ms
24,264 KB
testcase_05 AC 104 ms
23,508 KB
testcase_06 AC 107 ms
23,352 KB
testcase_07 AC 106 ms
23,412 KB
testcase_08 AC 105 ms
23,412 KB
testcase_09 AC 110 ms
23,364 KB
testcase_10 AC 108 ms
23,388 KB
testcase_11 AC 107 ms
24,000 KB
testcase_12 AC 105 ms
23,388 KB
testcase_13 AC 108 ms
24,012 KB
testcase_14 AC 107 ms
23,388 KB
testcase_15 AC 105 ms
23,628 KB
testcase_16 AC 106 ms
24,024 KB
testcase_17 AC 103 ms
23,424 KB
testcase_18 AC 105 ms
23,400 KB
testcase_19 AC 104 ms
24,024 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] = -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) {
			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