結果

問題 No.594 壊れた宝物発見機
ユーザー ats5515ats5515
提出日時 2017-11-10 22:51:23
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 107 ms / 2,000 ms
コード長 2,186 bytes
コンパイル時間 678 ms
コンパイル使用メモリ 86,368 KB
実行使用メモリ 24,348 KB
平均クエリ数 58.35
最終ジャッジ日時 2023-09-23 14:48:52
合計ジャッジ時間 4,079 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 105 ms
24,300 KB
testcase_01 AC 102 ms
23,700 KB
testcase_02 AC 101 ms
24,276 KB
testcase_03 AC 100 ms
23,568 KB
testcase_04 AC 100 ms
24,300 KB
testcase_05 AC 99 ms
23,760 KB
testcase_06 AC 102 ms
23,400 KB
testcase_07 AC 99 ms
23,976 KB
testcase_08 AC 102 ms
24,060 KB
testcase_09 AC 97 ms
23,964 KB
testcase_10 AC 107 ms
24,276 KB
testcase_11 AC 101 ms
23,772 KB
testcase_12 AC 99 ms
24,348 KB
testcase_13 AC 100 ms
23,580 KB
testcase_14 AC 99 ms
23,988 KB
testcase_15 AC 103 ms
23,868 KB
testcase_16 AC 100 ms
23,976 KB
testcase_17 AC 98 ms
23,652 KB
testcase_18 AC 100 ms
23,580 KB
testcase_19 AC 102 ms
24,060 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
map<pair<int, pair<int, int> >, int> mp;
int ask(int x, int y, int z) {
	int d;
	if (mp.count(make_pair(x, make_pair(y, z))) == 0) {
		cout << "?" << " " << x << " " << y << " " << z << endl;
		cin >> d;
		mp[make_pair(x, make_pair(y, z))] = d;
	}
	else {
		d = mp[make_pair(x, make_pair(y, z))];
	}
	return d;
}

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

signed main(void) {
	int a[3] = { 0, 0, 0 };
	int ans[3] = { 0, 0, 0 };
	int k;
	int u, d, m1, m2;
	int mn;

	int us, ds, ms1, ms2;
	int t;
	u = 100;
	d = -100;
	us = ask(u, a[1], a[2]);
	ds = ask(d, a[1], a[2]);
	//ms = ask(m, a[1], a[2]);
	while (u - d > 5) {
		m1 = (((u + 2 * d)) / 3);
		m2 = (((2 * u + d)) / 3);
		ms1 = ask(m1, a[1], a[2]);
		ms2 = ask(m2, a[1], a[2]);
		if (ms1 < ms2) {
			u = m2;
			us = ms2;
		}
		else {
			d = m1;
			ds = ms1;
		}
	}
	mn = (int)1 << 60;
	for (int i = d; i <= u; i++) {
		t = ask(i, a[1], a[2]);
		if (mn > t) {
			mn = t;
			ans[0] = i;
		}
	}
	u = 100;
	d = -100;
	us = ask(a[0], u, a[2]);
	ds = ask(a[0], d, a[2]);
	//ms = ask(m, a[1], a[2]);
	while (u - d > 5) {
		m1 = (((u + 2 * d)) / 3);
		m2 = (((2 * u + d)) / 3);
		ms1 = ask(a[0], m1, a[2]);
		ms2 = ask(a[0], m2, a[2]);
		if (ms1 < ms2) {
			u = m2;
			us = ms2;
		}
		else {
			d = m1;
			ds = ms1;
		}
	}
	mn = (int)1 << 60;
	for (int i = d; i <= u; i++) {
		t = ask(a[0], i, a[2]);
		if (mn > t) {
			mn = t;
			ans[1] = i;
		}
	}
	u = 100;
	d = -100;
	us = ask(a[0], a[1], u);
	ds = ask(a[0], a[1], d);
	//ms = ask(m, a[1], a[2]);
	while (u - d > 5) {
		m1 = (((u + 2 * d)) / 3);
		m2 = (((2 * u + d)) / 3);
		ms1 = ask(a[0], a[1], m1);
		ms2 = ask(a[0], a[1], m2);
		if (ms1 < ms2) {
			u = m2;
			us = ms2;
		}
		else {
			d = m1;
			ds = ms1;
		}
	}
	mn = (int)1 << 60;
	for (int i = d; i <= u; i++) {
		t = ask(a[0], a[1], i);
		if (mn > t) {
			mn = t;
			ans[2] = i;
		}
	}
	answer(ans[0], ans[1], ans[2]);
	return 0;
}
0