結果
| 問題 | No.594 壊れた宝物発見機 | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2017-11-10 22:49:39 | 
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 106 ms / 2,000 ms | 
| コード長 | 1,382 bytes | 
| コンパイル時間 | 1,167 ms | 
| コンパイル使用メモリ | 160,364 KB | 
| 実行使用メモリ | 25,232 KB | 
| 平均クエリ数 | 76.50 | 
| 最終ジャッジ日時 | 2024-07-16 14:27:43 | 
| 合計ジャッジ時間 | 4,435 ms | 
| ジャッジサーバーID (参考情報) | judge3 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 20 | 
ソースコード
#include<bits/stdc++.h>
#define REP(x,y,z) for(int x=y;x<=z;x++)
#define FORD(x,y,z) for(int x=y;x>=z;x--)
#define MSET(x,y) memset(x,y,sizeof(x))
#define FOR(x,y) for(__typeof(y.begin()) x=y.begin();x!=y.end();x++)
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define SZ size()
#define M 
void RI(){}
template<typename... T>
void RI( int& head, T&... tail ) {
    scanf("%d",&head);
    RI(tail...);
}
using namespace std;
typedef long long LL;
int ans[3];
// 質問クエリ
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;
}
void bs(int id) {
	int l=-100, r=100, m1, m2;
	int d1,d2;
	while(r-l>=3)
	{
		m1 = (r-l)/3;
		m2 = m1*2 + l;
		m1 += l;
		
		ans[id] = m1;
		d1 = ask(ans[0], ans[1], ans[2]);
		ans[id] = m2;
		d2 = ask(ans[0], ans[1], ans[2]);
		if(d1>=d2)
			l = m1;
		else
			r = m2;
	}
	if(l!=r)
	{
		ans[id] = l;
		int d0 = ask(ans[0], ans[1], ans[2]);
		int tmp = l;
		REP(i,l+1,r)
		{
			ans[id] = i;
			d1 = ask(ans[0], ans[1], ans[2]);
			if(d1<d0)
			{
				d0 = d1;
				tmp = i;
			}
		}
		ans[id] = tmp;
	}
	else
		ans[l] = l;
}
int main()
{
	ans[0] = ans[1] = ans[2] = 0;
	bs(0);bs(1);bs(2);
	answer(ans[0], ans[1], ans[2]);
	return 0;
}
            
            
            
        