結果

問題 No.513 宝探し2
ユーザー wunderkammer2wunderkammer2
提出日時 2019-12-16 12:45:43
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 32 ms / 2,000 ms
コード長 1,546 bytes
コンパイル時間 718 ms
コンパイル使用メモリ 91,988 KB
実行使用メモリ 24,240 KB
平均クエリ数 99.00
最終ジャッジ日時 2023-09-24 02:22:05
合計ジャッジ時間 2,089 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 32 ms
23,640 KB
testcase_01 AC 28 ms
23,436 KB
testcase_02 AC 28 ms
23,664 KB
testcase_03 AC 27 ms
24,048 KB
testcase_04 AC 28 ms
23,700 KB
testcase_05 AC 24 ms
23,556 KB
testcase_06 AC 27 ms
23,556 KB
testcase_07 AC 27 ms
24,024 KB
testcase_08 AC 24 ms
23,580 KB
testcase_09 AC 24 ms
24,096 KB
testcase_10 AC 27 ms
23,640 KB
testcase_11 AC 27 ms
24,240 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

using namespace std;
typedef long long ll;
const ll mod = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()

int main()
{	
	

	//x座標を決定
	//y座標を固定して、マンハッタン距離が最小値となるx座標を求める。
	//条件を満たすx座標が求まれば、y座標を求めることが可能。
	int left = 0;
	int right = 100000;

	//距離の最大値は(0, 0)から(100000, 100000)の200000
	int dmin = 200000;

	//最低98回試行可能。
	rep(i, 98 / 2)
	{
		cout << left << " " << 0 << endl;
		int d1 = 0;
		cin >> d1;

		cout << right << " " << 0 << endl;
		int d2 = 0;
		cin >> d2;

		int mid = (left + right) / 2;
		if (d2 > d1)
		{
			//右端のほうが遠いので、右端を置き換え
			right = mid;
			dmin = d1;
		}
		else if (d1 > d2)
		{
			//左端のほうが遠いので、左端を置き換え
			left = mid;
			dmin = d2;
		}
		else
		{
			//左端・右端からの距離が等しいので、両端を置き換え
			left = right = mid;
			dmin = d1;
		}
	}

	int x = right;


	//y座標を求める
	int y = dmin;


	//最終回答の提出
	cout << x << " " << y << endl;

	int d = 0;
	cin >> d;	

	return 0;
}
0