답안 #890407

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
890407 2023-12-21T06:06:44 Z Muhammad_Aneeq Aliens (IOI07_aliens) C++17
100 / 100
1 ms 692 KB
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
using namespace std;
#define int long long
int N,M;
map<pair<int,int>,bool>vis;
map<pair<int,int>,string>res;
int r=0;
string check(int x,int y)
{
	if (x<=0||x>N||y<=0||y>N)
		return "false";
	if (res[{x,y}]=="true"||res[{x,y}]=="false")
		return res[{x,y}];
	cout<<"examine "<<x<<' '<<y<<endl;
	r++;
	string z;
	cin>>z;
	res[{x,y}]=z;
	return z;
}
inline void solve()
{
	int x,y;
	cin>>N>>x>>y;
	vis={};
	res={};
	res[{x,y}]="true";
	int st=0,en=2;
	while (1)
	{
		int mid=(st+en)/2;
		if (check(x,y+mid)=="true")
			en*=2;
		else
			break;
	}
	en/=2;
	st=en/2-1;
	while (st+1<en)
	{
		int mid=(st+en)/2;
		if (check(x,y+mid)=="true")
			st=mid;
		else
			en=mid;
	}
	int ed=st;
	st=0,en=2;
	while (1)
	{
		int mid=en/2;
		if (check(x,y-mid)=="true")
			en*=2;
		else
			break;
	}
	en/=2;
	st=en/2-1;
	while (st+1<en)
	{
		int mid=(st+en)/2;
		if (check(x,y-mid)=="true")
			st=mid;
		else
			en=mid;
	}
	M=ed+en;
	y=(y+ed+y-st+1)/2;
	st=-(M/2)-1,en=M/2+1;
	while (st+1<en)
	{
		int mid=(st+en)/2;
		if (check(x+mid+(M/2),y)=="false")
			en=mid;
		else
			st=mid;
	}
	vis={};
	x=x+st;
	int z=0;
	if (check(x,y+2*M)=="true")
	{
		z++;
		if (check(x,y+4*M)=="true")
			z++;
	}
	int w=0;
	if (check(x,y-2*M)=="true")
	{
		w++;
		if (check(x,y-4*M)=="true")
			w++;
	}
	int u=0,o=0;
	if (check(x+2*M,y)=="true")
	{
		u++;
		if (check(x+4*M,y)=="true")
			u++;
	}
	if (check(x-2*M,y)=="true")
	{
		o++;
		if (check(x-4*M,y)=="true")
			o++;
	}
	cout<<"solution ";
	w=-w;
	o=-o;
	// cout<<x<<' '<<y<<' '<<(w+z)<<' '<<u+o<<endl;
	int ansx=x+(u+o)*M,ansy=y+(w+z)*M;
	cout<<ansx<<' '<<ansy<<endl;
}
signed main()
{
	solve();
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 436 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 436 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 436 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 440 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 436 KB Output is correct
2 Correct 1 ms 440 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 688 KB Output is correct
2 Correct 0 ms 432 KB Output is correct
3 Correct 1 ms 432 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 436 KB Output is correct
2 Correct 0 ms 432 KB Output is correct
3 Correct 1 ms 432 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 440 KB Output is correct
2 Correct 1 ms 436 KB Output is correct
3 Correct 0 ms 440 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 432 KB Output is correct
2 Correct 1 ms 440 KB Output is correct
3 Correct 1 ms 692 KB Output is correct