QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#17980 | #2213. Knight | laihaochen# | RE | 19ms | 11244kb | C++17 | 1.1kb | 2022-01-15 15:54:09 | 2022-05-04 16:34:29 |
Judging History
answer
#include <cstdio>
#include <algorithm>
using namespace std;
const int N = 1005;
int n, m, r, c, sx, sy, ex, ey;
char s[N][N];
int col[N][N];
int dx[] = {1, 1, -1, -1};
int dy[] = {1, -1, 1, -1};
int sz;
bool flag;
void dfs (int x, int y, int ch) {
sz++;
if (x == ex && y == ey) flag = 1;
col[x][y] = ch;
for (int i = 0; i < 4; i++) {
int nx = x + dx[i] * r, ny = y + dy[i] * c;
if (1 <= nx && nx <= n && 1 <= ny && ny <= m && s[nx][ny] != '@' && !col[nx][ny]) {
dfs (nx, ny, 3 - ch);
}
}
for (int i = 0; i < 4; i++) {
int nx = x + dx[i] * c, ny = y + dy[i] * r;
if (1 <= nx && nx <= n && 1 <= ny && ny <= m && s[nx][ny] != '@' && !col[nx][ny]) {
dfs (nx, ny, 3 - ch);
}
}
}
int main() {
scanf ("%d%d%d%d", &n, &m, &r, &c);
for (int i = 1; i <= n; i++) {
scanf ("%s", s[i] + 1);
for (int j = 1; j <= m; j++) {
if (s[i][j] == 'A') sx = i, sy = j;
if (s[i][j] == 'B') ex = i, ey = j;
}
}
dfs (sx, sy, 1);
if (sz == 1) {
printf ("Bob\n");
} else if (!flag) {
printf ("Alice\n");
} else {
printf (col[sz][sy] == col[ex][ey] ? "Alice\n" : "Bob\n");
}
return 0;
}
Details
Test #1:
score: 100
Accepted
time: 1ms
memory: 5832kb
Test #2:
score: 0
Accepted
time: 1ms
memory: 2004kb
Test #3:
score: 0
Accepted
time: 19ms
memory: 11244kb
Test #4:
score: -100
Runtime Error