結果

問題 No.513 宝探し2
ユーザー lapilapi
提出日時 2019-03-31 20:04:58
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 28 ms / 2,000 ms
コード長 1,543 bytes
コンパイル時間 942 ms
コンパイル使用メモリ 102,236 KB
実行使用メモリ 24,348 KB
平均クエリ数 28.58
最終ジャッジ日時 2023-09-24 02:11:27
合計ジャッジ時間 2,612 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
23,388 KB
testcase_01 AC 21 ms
23,652 KB
testcase_02 AC 24 ms
23,892 KB
testcase_03 AC 23 ms
23,892 KB
testcase_04 AC 23 ms
24,216 KB
testcase_05 AC 21 ms
23,568 KB
testcase_06 AC 21 ms
24,336 KB
testcase_07 AC 22 ms
23,592 KB
testcase_08 AC 22 ms
23,304 KB
testcase_09 AC 21 ms
23,892 KB
testcase_10 AC 22 ms
24,348 KB
testcase_11 AC 22 ms
23,292 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
#include <tuple>
#include<iomanip>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int up = 100001;
	int bottom = 0;

	int left = 0;
	int right = 100001;
	int ld, rd;
	
	

	cout << left << " " << up << endl; cin >> ld;
	cout << right << " " << up << endl; cin >> rd;

	while (true) {
		if (ld == rd) {
			int tmp= (left + right) / 2;
			left = right = tmp;
			break;
		}
		else if (ld < rd) {
			right = (left + right) / 2;
			cout << right << " " << up << endl; cin >> rd;
		}
		else { // rd < ld
			left = (left + right) / 2 + 1;
			cout << left << " " << up << endl; cin >> ld;
		}
	}
	
	
	bool flag = false;

	int ud, bd;
	
	cout << left << " " << up << endl; cin >> ud;
	cout << left << " " << bottom << endl; cin >> bd;
	
	if (bd == 0) flag = true;
	

	while (!flag) {
		if (bd == ud) {
			cout << left << " " << (bottom + up) / 2 << endl;
			cin >> bd;
			ud = bd;
			flag = true;
		}
		else if (bd < ud) {
			up = (bottom + up) / 2;
			cout << left << " " << up << endl; cin >> ud;
			if (ud == 0) flag = true;
		}
		else { // ud < bd
			bottom = (bottom + up) / 2 + 1;
			cout << left << " " << bottom << endl; cin >> bd;
			if (bd == 0) flag = true;
		}
	}

	return 0;
}
0