結果

問題 No.513 宝探し2
ユーザー finefine
提出日時 2017-05-05 23:05:30
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 28 ms / 2,000 ms
コード長 722 bytes
コンパイル時間 1,432 ms
コンパイル使用メモリ 164,176 KB
実行使用メモリ 24,396 KB
平均クエリ数 55.58
最終ジャッジ日時 2023-09-24 01:06:45
合計ジャッジ時間 2,679 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
23,604 KB
testcase_01 AC 26 ms
23,952 KB
testcase_02 AC 26 ms
23,580 KB
testcase_03 AC 26 ms
24,300 KB
testcase_04 AC 25 ms
23,580 KB
testcase_05 AC 26 ms
24,072 KB
testcase_06 AC 26 ms
23,316 KB
testcase_07 AC 25 ms
24,384 KB
testcase_08 AC 25 ms
23,436 KB
testcase_09 AC 25 ms
23,544 KB
testcase_10 AC 25 ms
24,012 KB
testcase_11 AC 25 ms
24,396 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int L = 0, R = 100000;
	while (R - L > 2) {
		int M1 = (L * 2 + R) / 3;
		cout << M1 << " " << 0 << endl;
		int v1;
		cin >> v1;
		if (v1 == 0) return 0;
		int M2 = (L + R * 2) / 3;
		cout << M2 << " " << 0 << endl;
		int v2;
		cin >> v2;
		if (v2 == 0) return 0;
		if (v1 > v2) L = M1;
		else R = M2;
	}

	int vr;
	cout << R << " " << 0 << endl;
	cin >> vr;
	if (vr == 0) return 0;
	int vl;
	cout << L << " " << 0 << endl;
	cin >> vl;
	if (vl == 0) return 0;
	if (vl < vr) cout << L << " " << vl <<  endl;
	else if (vl > vr) cout << R << " " << vr << endl;
	else cout << L + 1 << " " << vl - 1 << endl;

	return 0;
}
0