QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#53015#2213. KnightCoder_Z#WA 14ms8192kbC++141.3kb2022-10-04 17:08:252022-10-04 17:09:12

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-10-04 17:09:12]
  • 评测
  • 测评结果:WA
  • 用时:14ms
  • 内存:8192kb
  • [2022-10-04 17:08:25]
  • 提交

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