QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#53015 | #2213. Knight | Coder_Z# | WA | 14ms | 8192kb | C++14 | 1.3kb | 2022-10-04 17:08:25 | 2022-10-04 17:09:12 |
Judging History
answer
#include <bits/stdc++.h>
#define x first
#define y second
#define rep(i, a, b) for (int i = (a); i <= (b); i ++)
#define dep(i, a, b) for (int i = (a); i >= (b); i --)
using namespace std;
typedef pair <int, int> pii;
const int N = 1000 + 5;
char s[N][N];
int n, m, r, c, cnt;
int vis[N][N];
int ax, ay, bx, by;
queue <pii> q;
int main() {
cin >> n >> m >> r >> c;
if ( !r && !c )
return cout << "Bob", 0;
memset(vis, -1, sizeof vis);
int ways[8][2] = {{r, c}, {r, -c}, {-r, -c}, {c, r}, {c, -r}, {-c, r}, {-c, -r}};
rep(i, 1, n) {
cin >> (s[i] + 1);
rep(j, 1, m) {
if ( s[i][j] == 'A' ) ax = i, ay = j;
if ( s[i][j] == 'B' ) bx = i, by = j;
}
}
q.push({ax, ay});
vis[ax][ay] = 1;
while ( !q.empty() ) {
pii u = q.front();
q.pop();
rep(k, 0, 7) {
int mx = u.x + ways[k][0], my = u.y + ways[k][1];
if ( mx < 1 || my < 1 || mx > n || my > m ) continue;
if ( s[mx][my] == '@' || vis[mx][my] != 1 ) continue;
cnt ++;
vis[mx][my] = (vis[u.x][u.y] ^ 1);
q.push({mx, my});
}
}
if ( !cnt ) return cout << "Bob", 0;
if ( vis[bx][by] == -1 ) return cout << "Alice", 0;
if ( vis[ax][ay] == vis[bx][by] ) cout << "Alice";
else cout << "Bob";
return 0;
}
Details
Test #1:
score: 0
Wrong Answer
time: 14ms
memory: 8192kb