結果

問題 No.594 壊れた宝物発見機
ユーザー femtofemto
提出日時 2017-11-10 22:33:31
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 108 ms / 2,000 ms
コード長 813 bytes
コンパイル時間 1,517 ms
コンパイル使用メモリ 163,804 KB
実行使用メモリ 24,360 KB
平均クエリ数 50.60
最終ジャッジ日時 2023-09-23 14:44:52
合計ジャッジ時間 5,954 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 104 ms
24,360 KB
testcase_01 AC 95 ms
23,772 KB
testcase_02 AC 100 ms
23,304 KB
testcase_03 AC 99 ms
23,412 KB
testcase_04 AC 104 ms
23,412 KB
testcase_05 AC 102 ms
23,448 KB
testcase_06 AC 98 ms
23,580 KB
testcase_07 AC 101 ms
23,484 KB
testcase_08 AC 97 ms
23,352 KB
testcase_09 AC 100 ms
23,352 KB
testcase_10 AC 101 ms
23,868 KB
testcase_11 AC 102 ms
23,460 KB
testcase_12 AC 95 ms
24,000 KB
testcase_13 AC 99 ms
24,336 KB
testcase_14 AC 100 ms
23,316 KB
testcase_15 AC 108 ms
24,300 KB
testcase_16 AC 97 ms
23,760 KB
testcase_17 AC 97 ms
23,364 KB
testcase_18 AC 100 ms
23,676 KB
testcase_19 AC 97 ms
23,448 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

// 質問クエリ
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;
}

ll X[3];

// [from, to)
ll findMin(ll from, ll to, int idx){
	for(; to - from > 1;){
		ll mid = (from + to) / 2;
		X[idx] = mid - 1;
		ll d1 = ask(X[0], X[1], X[2]);
		X[idx] = mid;
		ll d2 = ask(X[0], X[1], X[2]);
		(d1 > d2 ? from : to) = mid;
	}
	return from;
}


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
#ifdef LOCAL
	std::ifstream in("in");
	std::cin.rdbuf(in.rdbuf());
#endif

	for(int i = 0; i < 3; i++){
		X[i] = findMin(-150, 151, i);
	}
	answer(X[0], X[1], X[2]);
}
0