Submission #436205

# Submission time Handle Problem Language Result Execution time Memory
436205 2021-06-24T10:24:12 Z dutch Aliens (IOI07_aliens) C++17
100 / 100
4 ms 320 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
 
int n, x, y;
 
bool q(int i, int j){
	if(min(i, j) < 1 || max(i, j) > n) return 0;
	cout << "examine " << i << ' ' << j << endl;
	string res; cin >> res;
	return res[0] == 't';
}
 
signed main(){
	cin.tie(0)->sync_with_stdio(0);
	cin >> n >> x >> y;
	int x0 = x, x1 = x, y1 = y;
 
	for(int i=1<<30; i/=2; ){
		if(q(x1+i/1, y) && q(x1+i/2, y) && q(x1+i/4, y)) x1 += i;
		if(q(x0-i/1, y) && q(x0-i/2, y) && q(x0-i/4, y)) x0 -= i;
		if(q(x, y1+i/1) && q(x, y1+i/2) && q(x, y1+i/4)) y1 += i;
	}
 
	int w = 2*(x1 - x0 + 1);
	int y0 = y1 - (x1 - x0);
	x = (x0 + x1) / 2;
	y = (y0 + y1) / 2;
 
	x0 = x1 = x;
	y0 = y1 = y;
 
	if(q(x0-w, y)) x0 -= w;
	if(q(x0-w, y)) x0 -= w;
	if(q(x1+w, y)) x1 += w;
	if(q(x1+w, y)) x1 += w;
 
	if(q(x, y0-w)) y0 -= w;
	if(q(x, y0-w)) y0 -= w;
	if(q(x, y1+w)) y1 += w;
	if(q(x, y1+w)) y1 += w;
 
	cout << "solution " << (x0+x1)/2 << ' ' << (y0+y1)/2 << endl;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 200 KB Output is correct
2 Correct 1 ms 200 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 200 KB Output is correct
2 Correct 2 ms 200 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 200 KB Output is correct
2 Correct 2 ms 200 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 200 KB Output is correct
2 Correct 2 ms 200 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 200 KB Output is correct
2 Correct 2 ms 200 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 200 KB Output is correct
2 Correct 2 ms 200 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 200 KB Output is correct
2 Correct 2 ms 200 KB Output is correct
3 Correct 2 ms 200 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 320 KB Output is correct
2 Correct 2 ms 200 KB Output is correct
3 Correct 3 ms 200 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 200 KB Output is correct
2 Correct 4 ms 200 KB Output is correct
3 Correct 3 ms 200 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 200 KB Output is correct
2 Correct 3 ms 200 KB Output is correct
3 Correct 4 ms 200 KB Output is correct