結果

問題 No.513 宝探し2
ユーザー tabataba
提出日時 2017-05-18 01:03:25
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 848 bytes
コンパイル時間 825 ms
コンパイル使用メモリ 84,004 KB
実行使用メモリ 36,212 KB
最終ジャッジ日時 2023-09-24 01:16:37
合計ジャッジ時間 7,181 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <random>
#include <vector>
#include <algorithm>
#include <array>

using namespace std;

const bool TEST=false;

int manhattan(int x1,int y1,int x2,int y2){
	return abs(x1-x2)+abs(y1-y2);
}

int getcount=0;
int get(int x,int y){
	getcount++;
	if(TEST){
		return manhattan(x,y,810,1919);
	}
	printf("%d %d\n",x,y);
	int mh;
	int _=scanf("%d",&mh);
	return mh;
}

int main(){
	random_device rd;
	mt19937 mt(rd());
	array<int,3> a;
	a[0]=a[1]=100000/2;
	a[2]=get(a[0],a[1]);
	while(a[2]){
		array<int,3> b;
		uniform_int_distribution<> xdist(a[0]-a[2],a[0]+a[2]);
		uniform_int_distribution<> ydist(a[1]-a[2],a[1]+a[2]);
		b[0]=xdist(mt);
		b[1]=ydist(mt);
		b[2]=get(b[0],b[1]);
		if(TEST){
			printf("%d,%d,%d\n",b[0],b[1],b[2]);
		}
		if(a[2]>b[2])
			a=b;
	}
	if(TEST){
		printf("getcount=%d\n",getcount);
	}
	return 0;
}
0