結果

問題 No.513 宝探し2
ユーザー snrnsidysnrnsidy
提出日時 2021-09-25 16:33:38
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,889 bytes
コンパイル時間 2,440 ms
コンパイル使用メモリ 210,528 KB
実行使用メモリ 24,228 KB
平均クエリ数 86.42
最終ジャッジ日時 2023-09-18 23:05:00
合計ジャッジ時間 3,819 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
23,508 KB
testcase_01 AC 27 ms
23,640 KB
testcase_02 AC 27 ms
24,072 KB
testcase_03 AC 28 ms
23,448 KB
testcase_04 AC 28 ms
23,604 KB
testcase_05 AC 27 ms
24,228 KB
testcase_06 AC 28 ms
24,024 KB
testcase_07 AC 27 ms
23,508 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 28 ms
23,868 KB
testcase_11 AC 27 ms
24,192 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

map <pair<int,int>,int> memo;
int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);

	int lo = 0;
	int hi = 100000;
	int x = 0;
	int y = 100000;

    while(hi-lo>=3)
	{
		int p = (2*lo + hi)/3;
		int q = (lo + 2*hi)/3;
		int d1,d2;
		if(memo.find(make_pair(p,y))==memo.end())
		{
    		cout << p << " " << y << endl;
    		cin>>d1;
    		if(d1==0)return 0;
			memo[make_pair(p,y)] = d1;
		}
		else d1 = memo[make_pair(p,y)];
		if(memo.find(make_pair(q,y))==memo.end())
		{
			cout << q << " " << y << endl;
			cin>>d2;
			if(d2==0)return 0;
			memo[make_pair(q,y)] = d2;
		}
		else
		{
			d2 = memo[make_pair(q,y)];
		}
		if(d1<=d2)
		{
			hi = q;
		}
		else{
			lo = p;
		}
  	}

	int res = 1e9;
	for(int i=lo;i<=hi;i++)
	{
		int d;
		if(memo.find(make_pair(i,y))==memo.end())
		{
			cout << i << " " << y << endl; 
			cin>>d;
			memo[make_pair(i,y)] = d;
			if(d==0) return 0;
		}
		else{
			d = memo[make_pair(i,y)];
		}
		if(res >= d)
		{
			res = d;
			x = i;
		}		
	}

	lo = 0;
	hi = 100000;
    while(hi-lo>=3)
	{
		int p = (2*lo + hi)/3;
		int q = (lo + 2*hi)/3;
		int d1,d2;
		if(memo.find(make_pair(x,p))==memo.end())
		{
    		cout << x << " " << p << endl;
    		cin>>d1;
    		if(d1==0)return 0;
			memo[make_pair(x,p)] = d1;
		}
		else d1 = memo[make_pair(x,p)];
		if(memo.find(make_pair(x,q))==memo.end())
		{
			cout << x << " " << q << endl;
			cin>>d2;
			if(d2==0)return 0;
			memo[make_pair(x,q)] = d2;
		}
		else
		{
			d2 = memo[make_pair(x,q)];
		}
		if(d1<=d2)
		{
			hi = q;
		}
		else{
			lo = p;
		}
  	}

	res = 1e9;
	for(int i=lo;i<=hi;i++)
	{
		int d;
		if(memo.find(make_pair(x,i))==memo.end())
		{
			cout << x << " " << i << endl; 
			cin>>d;
			memo[make_pair(x,i)] = d;
			if(d==0) return 0;
		}
		else{
			d = memo[make_pair(x,i)];
		}
		if(res >= d)
		{
			res = d;
			y = i;
		}		
	}

	return 0;
}
0