結果

問題 No.513 宝探し2
ユーザー umaumaxumaumax
提出日時 2017-05-05 23:01:38
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 996 bytes
コンパイル時間 450 ms
コンパイル使用メモリ 60,900 KB
実行使用メモリ 24,468 KB
平均クエリ数 37.50
最終ジャッジ日時 2023-09-23 13:29:51
合計ジャッジ時間 3,805 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 26 ms
23,640 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 24 ms
24,468 KB
testcase_09 AC 27 ms
23,328 KB
testcase_10 AC 33 ms
23,748 KB
testcase_11 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <functional>
#include <iostream>

using namespace std;

int main(int argc, const char* argv[])
{
	int lowX = 0;
	//	int lowY  = 0;
	int highX = 100000;
	//	int highY = 100000;
	int x	= 0;
	int y	= 0;
	auto fxy = [](int x, int y) {
		cout << x << " " << y << endl;
		int d;
		cin >> d;
		return d;
	};
	auto fyx = [](int x, int y) {
		cout << y << " " << x << endl;
		int d;
		cin >> d;
		return d;
	};
	//	auto f = fxy;
	function<int(int, int)> f = fxy;
	int i = 0;
	for (int k = 0; k < 2; k++) {
		for (; i < 100; i++) {
			int ld = f(lowX, y);
			if (ld == 0) return 0;
			int hd = f(highX, y);
			if (hd == 0) return 0;
			if (ld < hd) {
				x = ld;
				highX -= (highX - lowX) / 2;
				if (ld + 1 == hd) break;
			}
			if (ld > hd) {
				x = hd;
				lowX += (highX - lowX) / 2;
				if (ld - 1 == hd) break;
			}
			if (ld == hd) {
				x = (ld + hd) / 2;
				break;
			}
		}
		if (i == 100) break;
		y	 = x;
		x	 = 0;
		lowX  = 0;
		highX = 100000;
		f	 = fyx;
		i++;
	}
	return 0;
}
0