Submission #1348176

#TimeUsernameProblemLanguageResultExecution timeMemory
1348176jumpAliens (IOI07_aliens)C++20
40 / 100
1 ms436 KiB
#include <bits/stdc++.h>
#define int long long
int lim=10000000,x,y;
bool test(int tx,int ty){
	if(tx>lim||ty>lim||tx<=0||ty<=0)return false;
	std::cout << "examine " << tx << ' ' << ty << std::endl;
	std::string in;
	std::cin >> in;
	return in[0]=='t';
}
void ans(int tx,int ty){
	std::cout << "solution " << tx << ' ' << ty << std::endl;
}
bool up(int x,int y,int t){return test(x,y+t);}
bool down(int x,int y,int t){return test(x,y-t);}
bool left(int x,int y,int t){return test(x-t,y);}
bool right(int x,int y,int t){return test(x+t,y);}

int BST(std::function<bool(int,int,int)> f){
	int l=3;
	int upper=-1;
	int mid = 4;
	while(upper==-1){
		if(f(x,y,mid)){
			l=mid;
			mid*=2;
		}
		else{
			upper=mid;
		}
	}
	int h=upper-1;
	mid=(l+h+1)/2;
	while(l<h){
		if(f(x,y,mid)){
			l=mid;
		}
		else{
			h=mid-1;
		}
		mid=(l+h+1)/2;
	}
	return l;
}
void find(int range,int cx,int cy){
	bool lu1=test(cx-range,cy+range);
	bool lu2=test(cx-2*range,cy+2*range);
	bool ld1=test(cx-range,cy-range);
	bool ld2=test(cx-2*range,cy-2*range);
	bool ru1=test(cx+range,cy+range);
	bool ru2=test(cx+2*range,cy+2*range);
	bool rd1=test(cx+range,cy-range);
	bool rd2=test(cx+2*range,cy-2*range);
	bool l  =test(cx-2*range,cy);
	bool r  =test(cx+2*range,cy);
	bool u  =test(cx,cy+2*range);
	bool d  =test(cx,cy-2*range);
	bool notEdge = (ld1&&lu1&&ru1&&rd1);
	bool luEdge = (r&&d&&rd1);
	bool ldEdge = (r&&u&&ru1);
	bool ruEdge = (l&&d&&ld1);
	bool rdEdge = (l&&u&&lu1);
	if(lu2&ld2&ru2&rd2){
		ans(cx,cy);
	}	
	else if(d&&r&&notEdge){
		ans(cx+range,cy-range);
	}
	else if(r&&u&&notEdge){
		ans(cx+range,cy+range);
	}
	else if(l&&u&&notEdge){
		ans(cx-range,cy+range);
	}
	else if(l&&d&&notEdge){
		ans(cx-range,cy-range);
	}
	else if(luEdge&&ldEdge){
		ans(cx+2*range,cy);
	}
	else if(luEdge&&ruEdge){
		ans(cx,cy-2*range);
	}
	else if(ruEdge&&rdEdge){
		ans(cx-2*range,cy);
	}
	else if(ldEdge&&rdEdge){
		ans(cx,cy+2*range);
	}
	else if(luEdge){
		ans(cx+2*range,cy-2*range);
	}
	else if(ruEdge){
		ans(cx-2*range,cy-2*range);
	}
	else if(ldEdge){
		ans(cx+2*range,cy+2*range);
	}
	else if(rdEdge){
		ans(cx-2*range,cy+2*range);
	}
}
signed main() {
    std::ios::sync_with_stdio(false);std::cin.tie(nullptr);
	std::cin >> lim >> x >> y;
	int l=BST(left);
	int r=BST(right);
	int u=BST(up);
	int d=BST(down);
	//std::cout << l << ' ' << r << ' ' << u << ' ' << d << '\n';
	int m = (1+l+r);
	int cmx = x-l+m/2;
	int cmy = y-d+m/2;
	find(m,cmx,cmy);
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...