#pragma warning(disable : 4996)
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define L(i,j,k) for(int i=(j);i<=(k);i++)
#define R(i,j,k) for(int i=(j);i>=(k);i--)
ll n, x_given, y_given, sz, ansx, ansy;
void read() {
cin >> n >> x_given >> y_given;
return;
}
bool ask(int x, int y) {
cout << "examine " << x << ' ' << y << endl;
fflush(stdout);
string s; cin >> s;
return s == "true";
}
bool is_grass(int x, int y) {
if (x <= 0 || x >= n + 1 || y <= 0 || y >= n + 1) return false;
return ask(x, y);
}
pair<int, int> last_black(ll x, ll y, int dx, int dy) {
int l = 0, r = 60, meow = -1;
while (l <= r) {
int mid = (l + r) >> 1;
if (is_grass(x + dx * (1LL << mid), y + dy * (1LL << mid))) l = mid + 1, meow = mid;
else r = mid - 1;
}
if (meow==-1) return make_pair(x, y);
return last_black(x + dx * (1 << meow), y + dy * (1 << meow), dx, dy);
}
int count_block(int x, int y, int dx, int dy) {
int t = 1;
while (is_grass(x + dx * (2*sz) * t, y + dy * (2*sz) * t)) t++;
return t;
}
void is_centre(int x, int y) {
if (x <= 0 || x >= n + 1 || y <= 0 || y >= n + 1) return;
bool ok = true;
ok &= count_block(x, y, 1, 0) == 1;
ok &= count_block(x, y, -1, 0) == 1;
ok &= count_block(x, y, 0, 1) == 1;
ok &= count_block(x, y, 0, -1) == 1;
if (ok) {
ansx = x;
ansy = y;
//cout << "Yes this is the centre\n";
}
}
void find_centre() {
pair<int, int> a = last_black(x_given, y_given, 0, 1);
pair<int, int> b = last_black(x_given, y_given, 0, -1);
pair<int, int> c = last_black(x_given, y_given, 1, 0);
pair<int, int> d = last_black(x_given, y_given, -1, 0);
// cout << a.first << ' ' << a.second << '\n';
// cout << b.first << ' ' << b.second << '\n';
//cout << c.first << ' ' << c.second << '\n';
//cout << d.first << ' ' << d.second << '\n';
int difx = max({ a.first,b.first,c.first,d.first }) - min({ a.first,b.first,c.first,d.first });
int dify = max({ a.second,b.second,c.second,d.second }) - min({ a.second,b.second,c.second,d.second });
sz = difx + 1;
//cout << "size , sx , sy: ";
int midx = min({ a.first,b.first,c.first,d.first }) + difx / 2;
int midy = min({ a.second,b.second,c.second,d.second }) + dify / 2;
//cout << sz << ' ' << midx << ' ' << midy << '\n';
for (int i = -4; i <= 4; i++) {
for (int j = -4; j <= 4; j++) {
//cout << "checking if " << midx + i * sz << ' ' << midy + j * sz << " is a centre";
//cout << '\n';
is_centre(midx + i * sz, midy + j * sz);
}
}
cout << "solution " << (int)ansx << ' ' << (int)ansy << endl;
fflush(stdout);
}
int main() {
read();
/*R(i, n, 1) L(j, 1, n) {
char p; cin >> p;
if (p == '1') can[j][i] = 1;
else can[j][i] = 0;
} */
find_centre();
}
Compilation message
aliens.cpp:1: warning: ignoring '#pragma warning ' [-Wunknown-pragmas]
1 | #pragma warning(disable : 4996)
|
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Incorrect |
1 ms |
344 KB |
Incorrect |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Runtime error |
2 ms |
432 KB |
Execution killed with signal 13 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
2 ms |
436 KB |
Execution killed with signal 13 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
2 ms |
436 KB |
Execution killed with signal 13 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
436 KB |
Execution killed with signal 13 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
436 KB |
Execution killed with signal 13 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
2 ms |
432 KB |
Execution killed with signal 13 |
2 |
Halted |
0 ms |
0 KB |
- |