結果

問題 No.513 宝探し2
ユーザー finefine
提出日時 2017-05-05 23:05:30
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 24 ms / 2,000 ms
コード長 722 bytes
コンパイル時間 1,355 ms
コンパイル使用メモリ 168,060 KB
実行使用メモリ 25,476 KB
平均クエリ数 55.58
最終ジャッジ日時 2024-07-17 01:01:18
合計ジャッジ時間 2,453 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 12
権限があれば一括ダウンロードができます

ソースコード

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