QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#53047#2213. KnightCoder_Z#AC ✓85ms8676kbC++141.3kb2022-10-04 17:17:302022-10-04 17:17:35

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:17:35]
  • 评测
  • 测评结果:AC
  • 用时:85ms
  • 内存:8676kb
  • [2022-10-04 17:17:30]
  • 提交

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}, {-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: 100
Accepted
time: 7ms
memory: 8176kb

Test #2:

score: 0
Accepted
time: 1ms
memory: 7668kb

Test #3:

score: 0
Accepted
time: 16ms
memory: 8180kb

Test #4:

score: 0
Accepted
time: 23ms
memory: 8184kb

Test #5:

score: 0
Accepted
time: 0ms
memory: 7448kb

Test #6:

score: 0
Accepted
time: 10ms
memory: 8036kb

Test #7:

score: 0
Accepted
time: 2ms
memory: 7592kb

Test #8:

score: 0
Accepted
time: 0ms
memory: 7792kb

Test #9:

score: 0
Accepted
time: 20ms
memory: 8360kb

Test #10:

score: 0
Accepted
time: 6ms
memory: 8192kb

Test #11:

score: 0
Accepted
time: 2ms
memory: 8080kb

Test #12:

score: 0
Accepted
time: 8ms
memory: 8232kb

Test #13:

score: 0
Accepted
time: 5ms
memory: 7884kb

Test #14:

score: 0
Accepted
time: 10ms
memory: 8496kb

Test #15:

score: 0
Accepted
time: 0ms
memory: 8420kb

Test #16:

score: 0
Accepted
time: 9ms
memory: 8384kb

Test #17:

score: 0
Accepted
time: 2ms
memory: 7592kb

Test #18:

score: 0
Accepted
time: 0ms
memory: 7900kb

Test #19:

score: 0
Accepted
time: 2ms
memory: 7648kb

Test #20:

score: 0
Accepted
time: 0ms
memory: 8076kb

Test #21:

score: 0
Accepted
time: 0ms
memory: 7660kb

Test #22:

score: 0
Accepted
time: 2ms
memory: 7800kb

Test #23:

score: 0
Accepted
time: 4ms
memory: 7536kb

Test #24:

score: 0
Accepted
time: 13ms
memory: 8452kb

Test #25:

score: 0
Accepted
time: 2ms
memory: 8408kb

Test #26:

score: 0
Accepted
time: 4ms
memory: 7560kb

Test #27:

score: 0
Accepted
time: 4ms
memory: 7628kb

Test #28:

score: 0
Accepted
time: 19ms
memory: 8228kb

Test #29:

score: 0
Accepted
time: 0ms
memory: 7896kb

Test #30:

score: 0
Accepted
time: 6ms
memory: 8312kb

Test #31:

score: 0
Accepted
time: 8ms
memory: 7892kb

Test #32:

score: 0
Accepted
time: 2ms
memory: 7644kb

Test #33:

score: 0
Accepted
time: 28ms
memory: 8356kb

Test #34:

score: 0
Accepted
time: 0ms
memory: 8168kb

Test #35:

score: 0
Accepted
time: 20ms
memory: 8024kb

Test #36:

score: 0
Accepted
time: 13ms
memory: 8528kb

Test #37:

score: 0
Accepted
time: 9ms
memory: 7948kb

Test #38:

score: 0
Accepted
time: 10ms
memory: 7784kb

Test #39:

score: 0
Accepted
time: 0ms
memory: 7696kb

Test #40:

score: 0
Accepted
time: 7ms
memory: 8096kb

Test #41:

score: 0
Accepted
time: 8ms
memory: 8060kb

Test #42:

score: 0
Accepted
time: 0ms
memory: 7996kb

Test #43:

score: 0
Accepted
time: 8ms
memory: 8392kb

Test #44:

score: 0
Accepted
time: 6ms
memory: 7840kb

Test #45:

score: 0
Accepted
time: 0ms
memory: 8232kb

Test #46:

score: 0
Accepted
time: 1ms
memory: 7792kb

Test #47:

score: 0
Accepted
time: 2ms
memory: 8084kb

Test #48:

score: 0
Accepted
time: 26ms
memory: 8540kb

Test #49:

score: 0
Accepted
time: 12ms
memory: 8416kb

Test #50:

score: 0
Accepted
time: 0ms
memory: 7828kb

Test #51:

score: 0
Accepted
time: 72ms
memory: 8564kb

Test #52:

score: 0
Accepted
time: 39ms
memory: 8532kb

Test #53:

score: 0
Accepted
time: 8ms
memory: 8548kb

Test #54:

score: 0
Accepted
time: 37ms
memory: 8604kb

Test #55:

score: 0
Accepted
time: 25ms
memory: 8476kb

Test #56:

score: 0
Accepted
time: 65ms
memory: 8496kb

Test #57:

score: 0
Accepted
time: 59ms
memory: 8536kb

Test #58:

score: 0
Accepted
time: 4ms
memory: 8452kb

Test #59:

score: 0
Accepted
time: 24ms
memory: 8544kb

Test #60:

score: 0
Accepted
time: 70ms
memory: 8628kb

Test #61:

score: 0
Accepted
time: 18ms
memory: 8528kb

Test #62:

score: 0
Accepted
time: 14ms
memory: 8624kb

Test #63:

score: 0
Accepted
time: 72ms
memory: 8652kb

Test #64:

score: 0
Accepted
time: 22ms
memory: 8584kb

Test #65:

score: 0
Accepted
time: 21ms
memory: 8460kb

Test #66:

score: 0
Accepted
time: 8ms
memory: 8472kb

Test #67:

score: 0
Accepted
time: 39ms
memory: 8552kb

Test #68:

score: 0
Accepted
time: 13ms
memory: 8584kb

Test #69:

score: 0
Accepted
time: 76ms
memory: 8616kb

Test #70:

score: 0
Accepted
time: 32ms
memory: 8632kb

Test #71:

score: 0
Accepted
time: 19ms
memory: 8620kb

Test #72:

score: 0
Accepted
time: 18ms
memory: 8640kb

Test #73:

score: 0
Accepted
time: 20ms
memory: 8476kb

Test #74:

score: 0
Accepted
time: 58ms
memory: 8432kb

Test #75:

score: 0
Accepted
time: 18ms
memory: 8392kb

Test #76:

score: 0
Accepted
time: 24ms
memory: 8428kb

Test #77:

score: 0
Accepted
time: 69ms
memory: 8480kb

Test #78:

score: 0
Accepted
time: 15ms
memory: 8396kb

Test #79:

score: 0
Accepted
time: 20ms
memory: 8472kb

Test #80:

score: 0
Accepted
time: 62ms
memory: 8644kb

Test #81:

score: 0
Accepted
time: 18ms
memory: 8468kb

Test #82:

score: 0
Accepted
time: 19ms
memory: 8396kb

Test #83:

score: 0
Accepted
time: 13ms
memory: 8528kb

Test #84:

score: 0
Accepted
time: 12ms
memory: 8476kb

Test #85:

score: 0
Accepted
time: 14ms
memory: 8528kb

Test #86:

score: 0
Accepted
time: 16ms
memory: 8548kb

Test #87:

score: 0
Accepted
time: 20ms
memory: 8528kb

Test #88:

score: 0
Accepted
time: 17ms
memory: 8452kb

Test #89:

score: 0
Accepted
time: 58ms
memory: 8548kb

Test #90:

score: 0
Accepted
time: 18ms
memory: 8544kb

Test #91:

score: 0
Accepted
time: 2ms
memory: 8392kb

Test #92:

score: 0
Accepted
time: 28ms
memory: 8524kb

Test #93:

score: 0
Accepted
time: 11ms
memory: 8540kb

Test #94:

score: 0
Accepted
time: 67ms
memory: 8584kb

Test #95:

score: 0
Accepted
time: 23ms
memory: 8548kb

Test #96:

score: 0
Accepted
time: 26ms
memory: 8584kb

Test #97:

score: 0
Accepted
time: 77ms
memory: 8576kb

Test #98:

score: 0
Accepted
time: 66ms
memory: 8580kb

Test #99:

score: 0
Accepted
time: 19ms
memory: 8532kb

Test #100:

score: 0
Accepted
time: 12ms
memory: 8472kb

Test #101:

score: 0
Accepted
time: 21ms
memory: 8584kb

Test #102:

score: 0
Accepted
time: 9ms
memory: 8452kb

Test #103:

score: 0
Accepted
time: 61ms
memory: 8436kb

Test #104:

score: 0
Accepted
time: 20ms
memory: 8448kb

Test #105:

score: 0
Accepted
time: 27ms
memory: 8596kb

Test #106:

score: 0
Accepted
time: 22ms
memory: 8636kb

Test #107:

score: 0
Accepted
time: 65ms
memory: 8592kb

Test #108:

score: 0
Accepted
time: 62ms
memory: 8660kb

Test #109:

score: 0
Accepted
time: 65ms
memory: 8428kb

Test #110:

score: 0
Accepted
time: 38ms
memory: 8552kb

Test #111:

score: 0
Accepted
time: 50ms
memory: 8652kb

Test #112:

score: 0
Accepted
time: 17ms
memory: 8484kb

Test #113:

score: 0
Accepted
time: 19ms
memory: 8468kb

Test #114:

score: 0
Accepted
time: 15ms
memory: 8468kb

Test #115:

score: 0
Accepted
time: 20ms
memory: 8556kb

Test #116:

score: 0
Accepted
time: 19ms
memory: 8532kb

Test #117:

score: 0
Accepted
time: 24ms
memory: 8552kb

Test #118:

score: 0
Accepted
time: 14ms
memory: 8636kb

Test #119:

score: 0
Accepted
time: 18ms
memory: 8524kb

Test #120:

score: 0
Accepted
time: 85ms
memory: 8620kb

Test #121:

score: 0
Accepted
time: 22ms
memory: 8564kb

Test #122:

score: 0
Accepted
time: 11ms
memory: 8468kb

Test #123:

score: 0
Accepted
time: 13ms
memory: 8428kb

Test #124:

score: 0
Accepted
time: 25ms
memory: 8552kb

Test #125:

score: 0
Accepted
time: 42ms
memory: 8560kb

Test #126:

score: 0
Accepted
time: 16ms
memory: 8528kb

Test #127:

score: 0
Accepted
time: 16ms
memory: 8548kb

Test #128:

score: 0
Accepted
time: 14ms
memory: 8620kb

Test #129:

score: 0
Accepted
time: 20ms
memory: 8556kb

Test #130:

score: 0
Accepted
time: 23ms
memory: 8424kb

Test #131:

score: 0
Accepted
time: 24ms
memory: 8468kb

Test #132:

score: 0
Accepted
time: 62ms
memory: 8572kb

Test #133:

score: 0
Accepted
time: 12ms
memory: 8544kb

Test #134:

score: 0
Accepted
time: 14ms
memory: 8468kb

Test #135:

score: 0
Accepted
time: 78ms
memory: 8676kb

Test #136:

score: 0
Accepted
time: 14ms
memory: 8640kb

Test #137:

score: 0
Accepted
time: 15ms
memory: 8392kb

Test #138:

score: 0
Accepted
time: 56ms
memory: 8584kb

Test #139:

score: 0
Accepted
time: 8ms
memory: 8544kb

Test #140:

score: 0
Accepted
time: 14ms
memory: 8408kb

Test #141:

score: 0
Accepted
time: 39ms
memory: 8572kb

Test #142:

score: 0
Accepted
time: 11ms
memory: 8392kb

Test #143:

score: 0
Accepted
time: 62ms
memory: 8608kb

Test #144:

score: 0
Accepted
time: 21ms
memory: 8484kb

Test #145:

score: 0
Accepted
time: 55ms
memory: 8564kb

Test #146:

score: 0
Accepted
time: 20ms
memory: 8528kb

Test #147:

score: 0
Accepted
time: 29ms
memory: 8484kb

Test #148:

score: 0
Accepted
time: 67ms
memory: 8552kb

Test #149:

score: 0
Accepted
time: 34ms
memory: 8476kb

Test #150:

score: 0
Accepted
time: 71ms
memory: 8552kb

Test #151:

score: 0
Accepted
time: 63ms
memory: 8672kb

Test #152:

score: 0
Accepted
time: 14ms
memory: 8540kb

Test #153:

score: 0
Accepted
time: 8ms
memory: 8476kb

Test #154:

score: 0
Accepted
time: 15ms
memory: 8540kb

Test #155:

score: 0
Accepted
time: 85ms
memory: 8596kb

Test #156:

score: 0
Accepted
time: 27ms
memory: 8544kb

Test #157:

score: 0
Accepted
time: 14ms
memory: 8536kb

Test #158:

score: 0
Accepted
time: 17ms
memory: 8472kb

Test #159:

score: 0
Accepted
time: 18ms
memory: 8532kb

Test #160:

score: 0
Accepted
time: 28ms
memory: 8472kb

Test #161:

score: 0
Accepted
time: 47ms
memory: 8564kb

Test #162:

score: 0
Accepted
time: 19ms
memory: 8588kb

Test #163:

score: 0
Accepted
time: 18ms
memory: 8544kb

Test #164:

score: 0
Accepted
time: 41ms
memory: 8656kb

Test #165:

score: 0
Accepted
time: 53ms
memory: 8556kb

Test #166:

score: 0
Accepted
time: 76ms
memory: 8596kb