結果

問題 No.513 宝探し2
ユーザー gigimegigime
提出日時 2017-05-05 22:42:18
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 27 ms / 2,000 ms
コード長 1,040 bytes
コンパイル時間 1,788 ms
コンパイル使用メモリ 163,556 KB
実行使用メモリ 24,324 KB
平均クエリ数 67.17
最終ジャッジ日時 2023-09-24 01:03:31
合計ジャッジ時間 2,709 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
23,688 KB
testcase_01 AC 25 ms
23,964 KB
testcase_02 AC 23 ms
23,748 KB
testcase_03 AC 24 ms
23,988 KB
testcase_04 AC 22 ms
24,324 KB
testcase_05 AC 19 ms
24,240 KB
testcase_06 AC 21 ms
23,952 KB
testcase_07 AC 21 ms
23,736 KB
testcase_08 AC 21 ms
24,300 KB
testcase_09 AC 20 ms
23,952 KB
testcase_10 AC 22 ms
23,400 KB
testcase_11 AC 22 ms
23,964 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

#define FOR(i,l,r) for(int i = (int) (l);i < (int) (r);i++)
#define ALL(x) x.begin(),x.end()
template<typename T> bool chmax(T& a,const T& b){ return a < b ? (a = b,true) : false; }
template<typename T> bool chmin(T& a,const T& b){ return b < a ? (a = b,true) : false; }
typedef long long ll;

const int MAX = 100000;

int main()
{
	int loX = 0,hiX = MAX + 1,loY = 0,hiY = MAX + 1;
	while(hiX - loX > 1){
		int mid = (loX + hiX) / 2;
		int res1,res2;
		printf("%d %d\n",mid,loY);
		fflush(stdout);
		scanf("%d",&res1);
		printf("%d %d\n",mid - 1,loY);
		fflush(stdout);
		scanf("%d",&res2);
		if(res1 <= res2){
			loX = mid;
		}
		else{
			hiX = mid;
		}
	}
	while(hiY - loY > 1){
		int mid = (loY + hiY) / 2;
		int res1,res2;
		printf("%d %d\n",loX,mid);
		fflush(stdout);
		scanf("%d",&res1);
		printf("%d %d\n",loX,mid - 1);
		fflush(stdout);
		scanf("%d",&res2);
		if(res1 <= res2){
			loY = mid;
		}
		else{
			hiY = mid;
		}
	}
	printf("%d %d\n",loX,loY);
	fflush(stdout);

	return 0;
}
0