답안 #890403

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
890403 2023-12-21T06:02:06 Z Muhammad_Aneeq Aliens (IOI07_aliens) C++17
80 / 100
1 ms 440 KB
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
using namespace std;
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;
}
vector<pair<int,int>>ind;
void dfs1(int x,int y)
{
	if (x>N||y>N||x<=0||y<=0)
		return;
	if (vis[{x,y}])
		return;
	vis[{x,y}]=1;
	if (check(x,y)=="true")
	{
		ind.push_back({x,y});
		dfs1(x+2*M,y);dfs1(x-2*M,y);dfs1(x,y+2*M);dfs1(x,y-2*M);
	}
}
inline void solve()
{
	int x,y;
	cin>>N>>x>>y;
	vis={};
	res={};
	ind.push_back({x,y});
	res[{x,y}]=1;
	int st=0,en=2;
	while (1)
	{
		int mid=(st+en)/2;
		if (check(x,y+mid)=="true")
			en*=2;
		else
			break;
	}
	st=en/8;
	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;
	}
	st=en/8;
	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;
	}
	ind={};
	vis={};
	ind.push_back({x+st,y});
	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;
}
int main()
{
	solve();
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 428 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 432 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 436 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 432 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 436 KB Output is correct
2 Correct 1 ms 432 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 436 KB Output is correct
3 Correct 1 ms 432 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 432 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 Incorrect 1 ms 432 KB Incorrect
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 436 KB Output is correct
2 Incorrect 1 ms 432 KB Incorrect
3 Halted 0 ms 0 KB -