結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 109 ms
23,628 KB
testcase_01 AC 99 ms
23,820 KB
testcase_02 AC 101 ms
24,276 KB
testcase_03 AC 101 ms
23,640 KB
testcase_04 AC 102 ms
23,412 KB
testcase_05 AC 98 ms
23,580 KB
testcase_06 AC 99 ms
24,348 KB
testcase_07 AC 98 ms
24,348 KB
testcase_08 AC 100 ms
23,976 KB
testcase_09 AC 107 ms
24,024 KB
testcase_10 AC 101 ms
23,544 KB
testcase_11 AC 103 ms
24,048 KB
testcase_12 AC 101 ms
23,652 KB
testcase_13 AC 101 ms
24,324 KB
testcase_14 AC 103 ms
23,688 KB
testcase_15 AC 101 ms
23,412 KB
testcase_16 AC 98 ms
23,424 KB
testcase_17 AC 101 ms
24,336 KB
testcase_18 AC 103 ms
23,700 KB
testcase_19 AC 100 ms
24,360 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}

0