QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#17997#2213. Knightlinmuhan#AC ✓129ms14184kbC++111.5kb2022-01-15 16:54:302022-05-04 16:36:40

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-05-04 16:36:40]
  • 评测
  • 测评结果:AC
  • 用时:129ms
  • 内存:14184kb
  • [2022-01-15 16:54:30]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
const int N = 1100;
int s[N][N], xA, yA, xB, yB, n, m, r, c, cnt;
const int fx[4][2] = {{1, 1}, {-1, 1}, {-1, -1}, {1, -1}};
int colA[N][N];
char tmp;
struct node {
	int x, y, col;
};
queue <node> q;
bool vis[N][N];
bool valid (int xx, int yy) {
	return (xx >= 1 && xx <= n && yy >= 1 && yy <= m && ! vis[xx][yy] && s[xx][yy]);
}
void bfs (int sx, int sy, int col) {
	q.push ((node) {sx, sy, col});
	while (! q.empty ()) {
		cnt ++;
		node now = q.front (); q.pop ();
		for (int i=0;i<4;i++) {
			int xx = now.x + fx[i][0] * r, yy = now.y + fx[i][1] * c;
			if (valid (xx, yy)) {
				colA[xx][yy] = now.col ^ 1;
				vis[xx][yy] = 1;
				q.push ((node) {xx, yy, (now.col ^ 1)});
			}
		}
		for (int i=0;i<4;i++) {
			int xx = now.x + fx[i][0] * c, yy = now.y + fx[i][1] * r;
			if (valid (xx, yy)) {
				colA[xx][yy] = now.col ^ 1;
				vis[xx][yy] = 1;
				q.push ((node) {xx, yy, (now.col ^ 1)});
			}
		}
	}
}
int main () {
	cin >> n >> m >> r >> c;
	for (int i=1;i<=n;i++) {
		for (int j=1;j<=m;j++) {
			cin >> tmp;
			if (tmp == 'A') s[i][j] = 1, xA = i, yA = j;
			if (tmp == 'B') s[i][j] = 1, xB = i, yB = j;
			if (tmp == '@') s[i][j] = 0;
			if (tmp == '.') s[i][j] = 1;
		}
	}
	bfs (xA, yA, 8); // 8 9
	if (cnt <= 1) {
		puts ("Bob");
		return 0;
	}
	if (! colA[xB][yB]) {
		puts ("Alice");
		return 0;
	}
	if (colA[xB][yB] == 8) {
		puts ("Alice");
		return 0;
	}
	puts ("Bob");
	return 0;
}

详细

Test #1:

score: 100
Accepted
time: 15ms
memory: 9760kb

Test #2:

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

Test #3:

score: 0
Accepted
time: 36ms
memory: 13208kb

Test #4:

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

Test #5:

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

Test #6:

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

Test #7:

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

Test #8:

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

Test #9:

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

Test #10:

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

Test #11:

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

Test #12:

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

Test #13:

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

Test #14:

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

Test #15:

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

Test #16:

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

Test #17:

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

Test #18:

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

Test #19:

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

Test #20:

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

Test #21:

score: 0
Accepted
time: 3ms
memory: 5600kb

Test #22:

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

Test #23:

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

Test #24:

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

Test #25:

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

Test #26:

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

Test #27:

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

Test #28:

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

Test #29:

score: 0
Accepted
time: 3ms
memory: 5684kb

Test #30:

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

Test #31:

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

Test #32:

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

Test #33:

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

Test #34:

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

Test #35:

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

Test #36:

score: 0
Accepted
time: 33ms
memory: 12832kb

Test #37:

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

Test #38:

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

Test #39:

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

Test #40:

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

Test #41:

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

Test #42:

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

Test #43:

score: 0
Accepted
time: 30ms
memory: 11952kb

Test #44:

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

Test #45:

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

Test #46:

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

Test #47:

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

Test #48:

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

Test #49:

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

Test #50:

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

Test #51:

score: 0
Accepted
time: 91ms
memory: 13848kb

Test #52:

score: 0
Accepted
time: 57ms
memory: 13924kb

Test #53:

score: 0
Accepted
time: 43ms
memory: 13732kb

Test #54:

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

Test #55:

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

Test #56:

score: 0
Accepted
time: 80ms
memory: 13892kb

Test #57:

score: 0
Accepted
time: 75ms
memory: 13708kb

Test #58:

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

Test #59:

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

Test #60:

score: 0
Accepted
time: 89ms
memory: 13820kb

Test #61:

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

Test #62:

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

Test #63:

score: 0
Accepted
time: 95ms
memory: 13680kb

Test #64:

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

Test #65:

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

Test #66:

score: 0
Accepted
time: 44ms
memory: 13880kb

Test #67:

score: 0
Accepted
time: 44ms
memory: 13680kb

Test #68:

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

Test #69:

score: 0
Accepted
time: 95ms
memory: 13932kb

Test #70:

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

Test #71:

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

Test #72:

score: 0
Accepted
time: 36ms
memory: 13312kb

Test #73:

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

Test #74:

score: 0
Accepted
time: 84ms
memory: 13836kb

Test #75:

score: 0
Accepted
time: 44ms
memory: 13700kb

Test #76:

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

Test #77:

score: 0
Accepted
time: 89ms
memory: 13780kb

Test #78:

score: 0
Accepted
time: 43ms
memory: 12088kb

Test #79:

score: 0
Accepted
time: 44ms
memory: 9944kb

Test #80:

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

Test #81:

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

Test #82:

score: 0
Accepted
time: 45ms
memory: 13748kb

Test #83:

score: 0
Accepted
time: 48ms
memory: 8020kb

Test #84:

score: 0
Accepted
time: 40ms
memory: 13048kb

Test #85:

score: 0
Accepted
time: 45ms
memory: 11848kb

Test #86:

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

Test #87:

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

Test #88:

score: 0
Accepted
time: 40ms
memory: 11812kb

Test #89:

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

Test #90:

score: 0
Accepted
time: 48ms
memory: 13480kb

Test #91:

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

Test #92:

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

Test #93:

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

Test #94:

score: 0
Accepted
time: 92ms
memory: 13764kb

Test #95:

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

Test #96:

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

Test #97:

score: 0
Accepted
time: 92ms
memory: 14104kb

Test #98:

score: 0
Accepted
time: 88ms
memory: 13884kb

Test #99:

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

Test #100:

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

Test #101:

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

Test #102:

score: 0
Accepted
time: 36ms
memory: 12792kb

Test #103:

score: 0
Accepted
time: 94ms
memory: 13684kb

Test #104:

score: 0
Accepted
time: 44ms
memory: 13768kb

Test #105:

score: 0
Accepted
time: 45ms
memory: 13980kb

Test #106:

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

Test #107:

score: 0
Accepted
time: 75ms
memory: 13724kb

Test #108:

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

Test #109:

score: 0
Accepted
time: 93ms
memory: 13716kb

Test #110:

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

Test #111:

score: 0
Accepted
time: 89ms
memory: 13740kb

Test #112:

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

Test #113:

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

Test #114:

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

Test #115:

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

Test #116:

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

Test #117:

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

Test #118:

score: 0
Accepted
time: 40ms
memory: 10244kb

Test #119:

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

Test #120:

score: 0
Accepted
time: 102ms
memory: 13996kb

Test #121:

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

Test #122:

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

Test #123:

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

Test #124:

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

Test #125:

score: 0
Accepted
time: 79ms
memory: 13728kb

Test #126:

score: 0
Accepted
time: 45ms
memory: 13876kb

Test #127:

score: 0
Accepted
time: 48ms
memory: 11136kb

Test #128:

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

Test #129:

score: 0
Accepted
time: 43ms
memory: 11864kb

Test #130:

score: 0
Accepted
time: 81ms
memory: 13452kb

Test #131:

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

Test #132:

score: 0
Accepted
time: 126ms
memory: 13864kb

Test #133:

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

Test #134:

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

Test #135:

score: 0
Accepted
time: 103ms
memory: 14184kb

Test #136:

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

Test #137:

score: 0
Accepted
time: 51ms
memory: 13404kb

Test #138:

score: 0
Accepted
time: 109ms
memory: 13776kb

Test #139:

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

Test #140:

score: 0
Accepted
time: 64ms
memory: 12768kb

Test #141:

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

Test #142:

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

Test #143:

score: 0
Accepted
time: 90ms
memory: 13888kb

Test #144:

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

Test #145:

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

Test #146:

score: 0
Accepted
time: 51ms
memory: 13812kb

Test #147:

score: 0
Accepted
time: 45ms
memory: 13800kb

Test #148:

score: 0
Accepted
time: 103ms
memory: 14128kb

Test #149:

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

Test #150:

score: 0
Accepted
time: 129ms
memory: 13744kb

Test #151:

score: 0
Accepted
time: 115ms
memory: 13736kb

Test #152:

score: 0
Accepted
time: 36ms
memory: 12532kb

Test #153:

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

Test #154:

score: 0
Accepted
time: 52ms
memory: 11808kb

Test #155:

score: 0
Accepted
time: 113ms
memory: 13868kb

Test #156:

score: 0
Accepted
time: 45ms
memory: 11900kb

Test #157:

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

Test #158:

score: 0
Accepted
time: 40ms
memory: 11980kb

Test #159:

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

Test #160:

score: 0
Accepted
time: 36ms
memory: 13412kb

Test #161:

score: 0
Accepted
time: 64ms
memory: 13776kb

Test #162:

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

Test #163:

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

Test #164:

score: 0
Accepted
time: 98ms
memory: 13912kb

Test #165:

score: 0
Accepted
time: 60ms
memory: 13844kb

Test #166:

score: 0
Accepted
time: 105ms
memory: 13664kb