結果

問題 No.594 壊れた宝物発見機
ユーザー mtsdmtsd
提出日時 2017-11-10 22:51:50
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 113 ms / 2,000 ms
コード長 1,581 bytes
コンパイル時間 605 ms
コンパイル使用メモリ 71,804 KB
実行使用メモリ 24,288 KB
平均クエリ数 82.00
最終ジャッジ日時 2023-09-23 14:48:47
合計ジャッジ時間 3,994 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 113 ms
23,700 KB
testcase_01 AC 103 ms
24,060 KB
testcase_02 AC 100 ms
23,568 KB
testcase_03 AC 98 ms
23,400 KB
testcase_04 AC 102 ms
23,664 KB
testcase_05 AC 97 ms
24,072 KB
testcase_06 AC 101 ms
23,388 KB
testcase_07 AC 98 ms
23,256 KB
testcase_08 AC 101 ms
23,412 KB
testcase_09 AC 99 ms
24,048 KB
testcase_10 AC 104 ms
24,000 KB
testcase_11 AC 103 ms
24,060 KB
testcase_12 AC 102 ms
24,264 KB
testcase_13 AC 103 ms
23,616 KB
testcase_14 AC 103 ms
24,288 KB
testcase_15 AC 103 ms
23,436 KB
testcase_16 AC 101 ms
23,664 KB
testcase_17 AC 105 ms
23,436 KB
testcase_18 AC 105 ms
23,412 KB
testcase_19 AC 100 ms
23,664 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf  1000000007

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 main(){
	int xu=100,xl=-100,yu=100,yl=-100,zu=100,zl=-100;
	int x=0,y=0,z=0;
	while(1){
		if(xu-xl<=2)break;
		int d = (xu-xl)/3;
		int xa = xu-d;
		int xb = xl+d;
		int a = ask(xa,y,z);
		int b = ask(xb,y,z);
		if(a<=b){
			xl = xb;
		}else{
			xu = xa;
		}
	}
	int p;
	int t;
	p = ask(xl,y,z);
	x = xl;
	for(int i=xl+1;i<=xu;i++){
		t = ask(i,y,z);
		if(p>t){
			x = i;
			p = t;
		}
	}
	while(1){
		if(yu-yl<=2)break;
		int d = (yu-yl)/3;
		int ya = yu-d;
		int yb = yl+d;
		int a = ask(x,ya,z);
		int b = ask(x,yb,z);
		if(a<=b){
			yl = yb;
		}else{
			yu = ya;
		}
	}
	p = ask(x,yl,z);
	y = yl;
	for(int i=yl+1;i<=yu;i++){
		t = ask(x,i,z);
		if(p>t){
			y = i;
			p = t;
		}
	}
	while(1){
		if(zu-zl<=2)break;
		int d = (zu-zl)/3;
		int za = zu-d;
		int zb = zl+d;
		int a = ask(x,y,za);
		int b = ask(x,y,zb);
		if(a<=b){
			zl = zb;
		}else{
			zu = za;
		}
	}
	p = ask(x,y,zl);
	z = zl;
	for(int i=zl+1;i<=zu;i++){
		t = ask(x,y,i);
		if(p>t){
			z = i;
			p = t;
		}
	}
	answer(x,y,z);
	return 0;
}
0