結果

問題 No.513 宝探し2
ユーザー snrnsidy
提出日時 2021-09-25 16:27:52
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,902 bytes
コンパイル時間 2,565 ms
コンパイル使用メモリ 203,432 KB
最終ジャッジ日時 2025-01-24 18:09:47
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 6 WA * 6
権限があれば一括ダウンロードができます

ソースコード

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 = 50000;
	int y = 50000;

    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;
		}
		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;
		}
		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