結果

問題 No.594 壊れた宝物発見機
ユーザー HIR180HIR180
提出日時 2017-11-10 22:59:26
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 101 ms / 2,000 ms
コード長 1,773 bytes
コンパイル時間 1,255 ms
コンパイル使用メモリ 144,164 KB
実行使用メモリ 24,360 KB
平均クエリ数 46.60
最終ジャッジ日時 2023-09-23 14:49:45
合計ジャッジ時間 4,451 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 97 ms
23,424 KB
testcase_01 AC 92 ms
23,676 KB
testcase_02 AC 95 ms
24,012 KB
testcase_03 AC 94 ms
24,048 KB
testcase_04 AC 101 ms
23,580 KB
testcase_05 AC 97 ms
23,376 KB
testcase_06 AC 95 ms
24,276 KB
testcase_07 AC 93 ms
23,412 KB
testcase_08 AC 95 ms
23,448 KB
testcase_09 AC 93 ms
24,360 KB
testcase_10 AC 94 ms
24,024 KB
testcase_11 AC 93 ms
23,412 KB
testcase_12 AC 101 ms
23,376 KB
testcase_13 AC 94 ms
24,024 KB
testcase_14 AC 94 ms
24,336 KB
testcase_15 AC 92 ms
23,448 KB
testcase_16 AC 95 ms
23,652 KB
testcase_17 AC 95 ms
24,072 KB
testcase_18 AC 93 ms
24,036 KB
testcase_19 AC 96 ms
23,544 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int xx=12,yy=-78,zz=99;
// 質問クエリ
int ask(int x, int y, int z) {
	x-=200; y-=200; z-=200;
	int d;
/*	int X = (x-xx)*(x-xx)+(y-yy)*(y-yy)+(z-zz)*(z-zz);
	return X;*/
	cout << "?" << " " << x << " " << y << " " << z << endl;
	cin >> d;
	return d;
}

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

void calc(int xa,int xb,int ya,int yb,int za,int zb){
	if(xa == xb && ya == yb && za == zb){
		answer(xa,ya,za); return;
	}
	//cout<<xa<<xb<<ya<<yb<<za<<zb<<endl;
	if(za != zb){
		int mid = (za+zb)/2;
		int V = ask(xa,ya,mid);
		int VV = ask(xa,ya,mid+1);
		if(V < VV) return calc(xa,xb,ya,yb,za,mid);
		else return calc(xa,xb,ya,yb,mid+1,zb);
	}
	if(ya != yb){
		int mid = (ya+yb)/2;
		int V = ask(xa,mid,za);
		int VV = ask(xa,mid+1,za);
		if(V < VV) return calc(xa,xb,ya,mid,za,zb);
		else return calc(xa,xb,mid+1,yb,za,zb);
	}
	{
		int mid = (xa+xb)/2;
		int V = ask(mid,ya,za);
		int VV = ask(mid+1,ya,za);
		if(V < VV) return calc(xa,mid,ya,yb,za,zb);
		else return calc(mid+1,xb,ya,yb,za,zb);
	}
}
int main(void) {
	calc(-100+200,100+200,-100+200,100+200,-100+200,100+200);
	return 0;
}
0