Submission #121996

# Submission time Handle Problem Language Result Execution time Memory
121996 2019-06-27T10:36:25 Z khulegub Aliens (IOI07_aliens) C++14
Compilation error
0 ms 0 KB
#include<bits/stdc++.h>


using namespace std;




bool exam(int x, int y){
	if(x < 1 || y < 1) return 0;
	cout << "examine " << x << ' ' << y << endl;
	string ans;
	cin >> ans;
	return ans[0]=='t';
}
void sol(int x, int y){
	cout << "solution " << x << ' ' << y << endl;
}



int main(){
	// freopen("in.txt", "r", stdin);
	int n;
	// cin >> n;
	// for (int i = 1; i <= n; i++){
	// 	for (int j = 1; j <= n; j++){
	// 		cin >> arr[i][j];
	// 	}
	// }
	// int x0 = 5, y0 = 7;
	cin >> n >> x0 >> y0;
	int usreh = 1;
	while(exam(x0 + usreh, y0) == 1){
		usreh *= 2;
	}
	int l = 0, r = usreh;
	int mx = 0;
	while(l <= r){
		if(l == r){
			if(exam(x0 + l, y0)) mx = max(mx, l);
			break;
		}
		int mid = (l + r) / 2;
		if(exam(x0 + mid, y0)){
			mx = max(mx, mid);
			l = mid + 1;
		}
		else r = mid - 1;
	}
	int mxx = x0 + mx;
	usreh = 1;
	while(exam(x0 - usreh, y0) == 1){
		usreh *= 2;
	}
	l = 0, r = usreh;
	mx = 0;
	while(l <= r){
		if(l == r){
			if(exam(x0 - l, y0)) mx = max(mx, l);
			break;
		}
		int mid = (l + r) / 2;
		if(exam(x0 - mid, y0)){
			mx = max(mx, mid);
			l = mid + 1;
		}
		else r = mid - 1;
	}
	int mnx = x0 - mx;
	usreh = 1;
	while(exam(x0, y0 + usreh) == 1){
		usreh *= 2;
	}
	l = 0, r = usreh;
	mx = 0;
	while(l <= r){
		if(l == r){
			if(exam(x0, y0 + l)) mx = max(mx, l);
			break;
		}
		int mid = (l + r) / 2;
		if(exam(x0, y0 + mid)){
			mx = max(mx, mid);
			l = mid + 1;
		}
		else r = mid - 1;
	}
	int mxy = y0 + mx;
	usreh = 1;
	while(exam(x0, y0 - usreh) == 1){
		usreh *= 2;
	}
	l = 0, r = usreh;
	mx = 0;
	while(l <= r){
		if(l == r){
			if(exam(x0, y0 - l)) mx = max(mx, l);
			break;
		}
		int mid = (l + r) / 2;
		if(exam(x0, y0 - mid)){
			mx = max(mx, mid);
			l = mid + 1;
		}
		else r = mid - 1;
	}
	int mny = y0 - mx;
	int m = mxy - mny + 1;
	int cntrx = (mnx + mxx) >> 1;
	int cntry = (mny + mxy) >> 1;
	usreh = 1;
	while (exam(cntrx + usreh * 2 * m, cntry)){
		usreh *= 2;
	}
	l = 0, r = usreh;
	mx = 0;
	while (l <= r){
		if(l == r){
			if(exam(cntrx + l * 2 * m, cntry)) mx = max(mx, l);
			break;
		}
		int mid = (l + r) >> 1;
		if(exam(cntrx + mid * 2 * m, cntry)){
			mx = max(mx, mid);
			l = mid + 1;
		}
		else r = mid - 1;
	}
	int xmax = mx;
	usreh = 1;
	while (exam(cntrx - usreh * 2 * m, cntry)){
		usreh *= 2;
	}
	l = 0, r = usreh;
	mx = 0;
	while (l <= r){
		if(l == r){
			if(exam(cntrx - l * 2 * m, cntry)) mx = max(mx, l);
			break;
		}
		int mid = (l + r) >> 1;
		if(exam(cntrx - mid * 2 * m, cntry)){
			mx = max(mx, mid);
			l = mid + 1;
		}
		else r = mid - 1;
	}
	int xmin = mx;
	usreh = 1;
	while (exam(cntrx , cntry + usreh * 2 * m)){
		usreh *= 2;
	}
	l = 0, r = usreh;
	mx = 0;
	while (l <= r){
		if(l == r){
			if(exam(cntrx, cntry  + l * 2 * m)) mx = max(mx, l);
			break;
		}
		int mid = (l + r) >> 1;
		if(exam(cntrx, cntry  + mid * 2 * m)){
			mx = max(mx, mid);
			l = mid + 1;
		}
		else r = mid - 1;
	}
	int ymax = mx;
	usreh = 1;
	while (exam(cntrx , cntry - usreh * 2 * m)){
		usreh *= 2;
	}
	l = 0, r = usreh;
	mx = 0;
	while (l <= r){
		if(l == r){
			if(exam(cntrx, cntry  - l * 2 * m)) mx = max(mx, l);
			break;
		}
		int mid = (l + r) >> 1;
		if(exam(cntrx, cntry - mid * 2 * m)){
			mx = max(mx, mid);
			l = mid + 1;
		}
		else r = mid - 1;
	}
	int ymin = mx;
	int wewe = xmax + xmin + 1;
	int hehe = ymax + ymin + 1;
	wewe /= 2;
	hehe /= 2;
	int xexe = cntrx + 2 * m * (wewe - xmin);
	int yeye = cntry + 2 * m * (hehe - ymin);
	sol(yeye, n -xexe +1);
	// cout << yeye << ' ' << n - xexe + 1;
}

Compilation message

aliens.cpp: In function 'int main()':
aliens.cpp:32:14: error: 'x0' was not declared in this scope
  cin >> n >> x0 >> y0;
              ^~
aliens.cpp:32:14: note: suggested alternative: 'y0'
  cin >> n >> x0 >> y0;
              ^~
              y0
aliens.cpp:72:20: warning: pointer to a function used in arithmetic [-Wpointer-arith]
  while(exam(x0, y0 + usreh) == 1){
                 ~~~^~~~~~~
aliens.cpp:79:19: warning: pointer to a function used in arithmetic [-Wpointer-arith]
    if(exam(x0, y0 + l)) mx = max(mx, l);
                ~~~^~~
aliens.cpp:83:18: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   if(exam(x0, y0 + mid)){
               ~~~^~~~~
aliens.cpp:89:15: warning: pointer to a function used in arithmetic [-Wpointer-arith]
  int mxy = y0 + mx;
            ~~~^~~~
aliens.cpp:89:15: error: invalid conversion from 'double (*)(double) throw ()' to 'int' [-fpermissive]
aliens.cpp:91:20: warning: pointer to a function used in arithmetic [-Wpointer-arith]
  while(exam(x0, y0 - usreh) == 1){
                 ~~~^~~~~~~
aliens.cpp:98:19: warning: pointer to a function used in arithmetic [-Wpointer-arith]
    if(exam(x0, y0 - l)) mx = max(mx, l);
                ~~~^~~
aliens.cpp:102:18: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   if(exam(x0, y0 - mid)){
               ~~~^~~~~
aliens.cpp:108:15: warning: pointer to a function used in arithmetic [-Wpointer-arith]
  int mny = y0 - mx;
            ~~~^~~~
aliens.cpp:108:15: error: invalid conversion from 'double (*)(double) throw ()' to 'int' [-fpermissive]