답안 #616091

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
616091 2022-07-31T20:25:05 Z Apiram Aliens (IOI07_aliens) C++14
80 / 100
2 ms 208 KB
#include<bits/stdc++.h>
using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	long long n,x,y;cin>>n>>x>>y;
	--x,--y;
	auto examine = [&](long long xx,long long yy){
		if (xx + 1 > n || yy + 1 > n || xx + 1<=0 || yy + 1<=0)return false;
		cout<<"examine "<<xx + 1<<" "<<yy + 1<<endl;
		string s;cin>>s;
		return s == "true";
	};
	auto answer = [&](long long xx,long long yy){
		assert(xx + 1 <=n && yy + 1 <=n && xx + 1 > 0 && yy + 1 > 0);
		cout<<"solution "<<xx + 1<<" "<<yy + 1<<endl;
	};
	long long pos = -1;
	for (int t = 0;t<1;++t){
		for (long long i = 0;i<=32;++i){
			if (examine(x - (1LL<<i),y)){
				pos = i;
			}
			else break;
		}
		if (pos == -1)break;
		long long left = (1LL<<pos),right = (1LL<<(pos + 1)) - 1;
		long long p = 0;
		while(left<=right){
			long long mid = (left + right)>>1;
			if (examine(x - mid,y)){
				left = mid + 1;
				p = mid;
			}
			else right = mid - 1;
		}
		x-=p;
	}
	pos = max(pos,0LL);
	long long m = 0;
	for (int t = 0;t<1;++t){
		for (long long i = pos;i<=32;++i){
			if (examine(x + (1LL<<i),y)){
				pos = i;
			}
			else break;
		}
		long long left = (1LL<<pos),right = (1LL<<(pos + 1)) - 1;
		while(left<=right){
			long long mid = (left + right)>>1;
			if (examine(x + mid,y)){
				left = mid + 1;
				m = mid;
			}
			else right = mid - 1;
		}
	}
	int lg = log2(m);
	while (true){
		long long pos = -1;
		for (long long i = lg;i>=0;--i){
			if (examine(x,y - (1LL<<i))){
				pos = i;
				lg = i - 1;
				break;
			}
		}
		if (pos == -1)break;
		y-=(1LL<<pos);
	}
	//cout<<x<<" "<<y<<" "<<m<<'\n';
	long long levelx = 0;
	if (examine(x + 4 * (m + 1) + m,y)){
		levelx = 1;
	}
	else if (examine(x + 2 * (m + 1) + m,y)){
		levelx = 2;
	}
	else levelx = 3;
	long long levely = 0;
	if (examine(x,y + 4 * (m + 1) + m)){
		levely = 1;
	}
	else if (examine(x,y + 2 * (m + 1) + m)){
		levely = 2;
	}
	else levely = 3;
	if (levelx == 1 && levely == 1){
		answer(x + (m + 1) + m + (m + 2)/2, y + (m + 1) + m + (m + 2)/2);
	}
	else if (levelx ==  1 && levely == 2){
		answer(x + (m + 1) + m + (m + 2)/2, y + (m + 1)/2);
	}
	else if (levelx == 1 && levely == 3){
		x+=m;
		answer(x + (m + 1) + (m + 2)/2,y - (m + 1) - (m + 2)/2);
	}
	else if (levelx == 2 && levely == 1){
		x+=(m + 1)/2;
		answer(x,y + (m + 1) + m + (m + 2)/2);
	}
	else if (levelx ==  2 && levely == 2){
		if (examine(x + m + 3 * (m + 1),y + m + 3 * (m + 1))){
			answer(x + m + (m + 2)/2,y +  m + (m + 2)/2);
		}
		else{
			answer(x + (m + 1)/2,y + (m + 1)/2);
		}
	}
	else if (levelx == 2 && levely == 3){
		if (examine(x - (m + 1),y)){
			x+=(m + 1)/2;
			answer(x,y - (m + 1) - (m + 2)/2);
		}
		else{
			x+=m;
			answer(x  + (m + 2)/2,y - (m + 2)/2);
		}
	}
	else if (levelx == 3 && levely == 1){
		y+=m;
		answer(x - (m + 1) - (m + 2)/2,y + (m + 1) + (m + 2)/2);
	}
	else if (levelx == 3 && levely == 2){
		if (examine(x - 4 * (m + 1),y)){
			y +=(m + 1)/2;
			answer(x - (m + 1) - (m + 2)/2,y);
		}
		else{
			y+=m;
			answer(x - (m + 2)/2 , y + (m + 2)/2);
		}
	}
	else if (levelx == 3 && levely == 3){
		if (examine(x,y - 4 * (m + 1))){
			answer(x - (m + 1) - (m + 2)/2,y - (m + 1) - (m + 2)/2);
		}
		else{
			answer(x - (m + 2)/2,y - (m + 2)/2);
		}
	}
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 208 KB Incorrect
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 208 KB Incorrect
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
3 Correct 2 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 2 ms 208 KB Output is correct
3 Correct 1 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
3 Correct 2 ms 208 KB Output is correct