# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
302876 |
2020-09-19T11:15:08 Z |
Akashi |
Aliens (IOI07_aliens) |
C++14 |
|
2 ms |
256 KB |
#include <bits/stdc++.h>
using namespace std;
bool debug = false;
int n, x, y;
char s[15];
bool f[105][105];
bool ask(int x, int y) {
if (x <= 0 || y <= 0 || x > n || y > n) return false;
bool ok = false;
cout << "examine " << x << " " << y;
cout << endl;
if (!debug) {
scanf("%s", s);
if (s[0] == 't') ok = true;
return ok;
}
else return f[x][y];
}
void found(int x, int y) {
cout << "solution " << x << " " << y;
cout << endl;
}
int find_dir(int x, int y, int sgn) {
int wh = 0;
for (int bit = 1; bit <= n ; bit = bit << 1) {
bool ok = ask(x + bit * sgn, y);
if (!ok) {wh = bit >> 1; break ;}
}
if (wh == 0) return 0;
int ans = 0;
for (int bit = wh; bit >= 1 ; bit = bit >> 1) {
bool ok = ask(x + bit * sgn, y);
if (ok) x += (bit * sgn), ans = ans + bit;
}
return ans;
}
void corect(int &x, int &y, int m) {
while (x > 0 && y > 0) {
bool ok = ask(x - m, y - m);
if (ok) x -= m, y -= m;
else break ;
}
while (x > 0) {
bool ok = ask(x - m, y);
if (ok) x -= m;
else break ;
}
while (y > 0) {
bool ok = ask(x, y - m);
if (ok) y -= m;
else break ;
}
for (int bit = (1 << 30); bit >= 1 ; bit = bit >> 1) {
bool ok = ask(x - bit, y);
if (ok) x -= bit;
}
for (int bit = (1 << 30); bit >= 1 ; bit = bit >> 1) {
bool ok = ask(x, y - bit);
if (ok) y -= bit;
}
}
void init() {
int n, m;
scanf("%d%d", &n, &m);
for (int i = 1; i <= 5 ; ++i) {
for (int j = 1; j <= 5 ; ++j) {
if ((i + j) % 2 == 0) {
for (int x = 1 + (i - 1) * m; x <= i * m ; ++x)
for (int y = 1 + (j - 1) * m ; y <= j * m ; ++y)
f[x][y] = 1;
}
}
}
for (int i = 1; i <= n ; ++i) {
for (int j = 1; j <= n ; ++j)
cerr << f[i][j];
cerr << endl;
}
}
int main() {
if (debug)
init();
cin >> n >> x >> y;
int up = find_dir(x, y, -1);
int down = find_dir(x, y, 1);
int m = up + down + 1;
corect(x, y, m);
found(x + 2 * m + m / 2, y + 2 * m + m / 2);
return 0;
}
Compilation message
aliens.cpp: In function 'bool ask(int, int)':
aliens.cpp:18:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
18 | scanf("%s", s);
| ~~~~~^~~~~~~~~
aliens.cpp: In function 'void init()':
aliens.cpp:80:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
80 | scanf("%d%d", &n, &m);
| ~~~~~^~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
256 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Incorrect |
1 ms |
256 KB |
Incorrect |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
256 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
1 ms |
256 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
1 ms |
256 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Incorrect |
2 ms |
256 KB |
Incorrect |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
1 ms |
256 KB |
Output is correct |
3 |
Correct |
1 ms |
256 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
256 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
256 KB |
Output is correct |
3 |
Incorrect |
1 ms |
256 KB |
Incorrect |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
256 KB |
Output is correct |
3 |
Incorrect |
2 ms |
256 KB |
Incorrect |