結果

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

テストケース

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

ソースコード

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 = 0;

	for(int i=0;i<50;i++)
	{
		if(hi-lo<3) break;
		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;
	for(int i=0;i<50;i++)
	{
		if(hi-lo<3) break;
		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;
		}		
	}

	cout << x << " " << y << endl;
	int d;
	cin>>d;
	if(d==0) return 0;	
	return 0;
}
0