#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--)
int n, x_given, y_given, sz;
void read() {
cin >> n >> x_given >> y_given;
return;
}
bool ask(int x, int y) {
cout << "examine " << x << ' ' << y << endl;
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(int x, int y, int dx, int dy) {
int t = 0;
while (is_grass(x + dx * (1 << (t + 1)), y + dy * (1 << (t + 1)))) t++;
if (t == 0) return make_pair(x, y);
return last_black(x + dx * (1 << t), y + dy * (1 << t), dx, dy);
}
int count_block(int x, int y, int dx, int dy) {
int t = 0;
while (is_grass(x + dx * sz * t, y + dy * 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) {
cout << "solution: " << x << ' ' << y << endl;
exit(0);
}
}
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);
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;
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;
for (int i = -4; i <= 4; i++) {
for (int j = -4; j <= 4; j++) {
is_centre(midx + i * sz, midy + j * sz);
}
}
}
int main() {
read();
find_centre();
}
Compilation message
aliens.cpp:1: warning: ignoring '#pragma warning ' [-Wunknown-pragmas]
1 | #pragma warning(disable : 4996)
|
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
436 KB |
Execution killed with signal 13 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Unexpected end of file - token expected |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Unexpected end of file - token expected |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
600 KB |
Unexpected end of file - token expected |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Unexpected end of file - token expected |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Unexpected end of file - token expected |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Unexpected end of file - token expected |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
344 KB |
Unexpected end of file - token expected |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
432 KB |
Execution killed with signal 13 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Unexpected end of file - token expected |
2 |
Halted |
0 ms |
0 KB |
- |