結果

問題 No.594 壊れた宝物発見機
ユーザー e869120e869120
提出日時 2017-11-10 22:39:02
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 109 ms / 2,000 ms
コード長 958 bytes
コンパイル時間 2,378 ms
コンパイル使用メモリ 77,380 KB
実行使用メモリ 24,384 KB
平均クエリ数 127.00
最終ジャッジ日時 2023-09-23 14:46:27
合計ジャッジ時間 4,431 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 109 ms
24,372 KB
testcase_01 AC 105 ms
24,060 KB
testcase_02 AC 105 ms
23,424 KB
testcase_03 AC 106 ms
23,568 KB
testcase_04 AC 105 ms
23,532 KB
testcase_05 AC 104 ms
24,048 KB
testcase_06 AC 102 ms
23,676 KB
testcase_07 AC 105 ms
23,676 KB
testcase_08 AC 107 ms
24,348 KB
testcase_09 AC 104 ms
24,360 KB
testcase_10 AC 103 ms
24,048 KB
testcase_11 AC 102 ms
23,664 KB
testcase_12 AC 104 ms
24,360 KB
testcase_13 AC 101 ms
24,336 KB
testcase_14 AC 105 ms
23,568 KB
testcase_15 AC 104 ms
23,640 KB
testcase_16 AC 105 ms
24,024 KB
testcase_17 AC 104 ms
24,240 KB
testcase_18 AC 105 ms
24,384 KB
testcase_19 AC 106 ms
23,364 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

// 質問クエリ
int ask(int x, int y, int z) {
	int d;
	cout << "?" << " " << x << " " << y << " " << z << endl;
	cin >> d;
	return d;
}

// 回答クエリ
void answer(int x, int y, int z) {
	cout << "!" << " " << x << " " << y << " " << z << endl;
}

int Get(int u) {
	vector<pair<int, int>>V;
	for (int i = -100; i <= 100; i += 10) {
		int c[3] = { -100,-100,-100 };
		c[u] = i;
		int D = ask(c[0], c[1], c[2]);
		V.push_back(make_pair(D, i));
	}
	sort(V.begin(), V.end());
	int minx = 100, maxn = -100;
	for (int i = 0; i < 3; i++) { minx = min(minx, V[i].second); maxn = max(maxn, V[i].second); }
	V.clear();
	for (int i = minx; i <= maxn; i++) {
		int c[3] = { -100,-100,-100 };
		c[u] = i;
		int D = ask(c[0], c[1], c[2]);
		V.push_back(make_pair(D, i));
	}
	sort(V.begin(), V.end());
	return V[0].second;
}

int main() {
	answer(Get(0), Get(1), Get(2));
	return 0;
}
0