QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#17981#2213. Knightlaihaochen#AC ✓79ms61800kbC++171.1kb2022-01-15 15:55:022022-05-04 16:34:31

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:34:31]
  • 评测
  • 测评结果:AC
  • 用时:79ms
  • 内存:61800kb
  • [2022-01-15 15:55:02]
  • 提交

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[sx][sy] == col[ex][ey] ? "Alice\n" : "Bob\n");
	}
	return 0;
} 

Details

Test #1:

score: 100
Accepted
time: 0ms
memory: 2324kb

Test #2:

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

Test #3:

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

Test #4:

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

Test #5:

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

Test #6:

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

Test #7:

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

Test #8:

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

Test #9:

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

Test #10:

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

Test #11:

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

Test #12:

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

Test #13:

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

Test #14:

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

Test #15:

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

Test #16:

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

Test #17:

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

Test #18:

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

Test #19:

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

Test #20:

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

Test #21:

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

Test #22:

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

Test #23:

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

Test #24:

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

Test #25:

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

Test #26:

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

Test #27:

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

Test #28:

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

Test #29:

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

Test #30:

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

Test #31:

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

Test #32:

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

Test #33:

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

Test #34:

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

Test #35:

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

Test #36:

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

Test #37:

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

Test #38:

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

Test #39:

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

Test #40:

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

Test #41:

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

Test #42:

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

Test #43:

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

Test #44:

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

Test #45:

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

Test #46:

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

Test #47:

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

Test #48:

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

Test #49:

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

Test #50:

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

Test #51:

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

Test #52:

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

Test #53:

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

Test #54:

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

Test #55:

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

Test #56:

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

Test #57:

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

Test #58:

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

Test #59:

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

Test #60:

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

Test #61:

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

Test #62:

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

Test #63:

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

Test #64:

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

Test #65:

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

Test #66:

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

Test #67:

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

Test #68:

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

Test #69:

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

Test #70:

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

Test #71:

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

Test #72:

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

Test #73:

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

Test #74:

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

Test #75:

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

Test #76:

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

Test #77:

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

Test #78:

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

Test #79:

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

Test #80:

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

Test #81:

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

Test #82:

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

Test #83:

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

Test #84:

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

Test #85:

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

Test #86:

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

Test #87:

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

Test #88:

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

Test #89:

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

Test #90:

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

Test #91:

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

Test #92:

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

Test #93:

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

Test #94:

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

Test #95:

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

Test #96:

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

Test #97:

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

Test #98:

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

Test #99:

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

Test #100:

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

Test #101:

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

Test #102:

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

Test #103:

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

Test #104:

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

Test #105:

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

Test #106:

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

Test #107:

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

Test #108:

score: 0
Accepted
time: 73ms
memory: 41972kb

Test #109:

score: 0
Accepted
time: 46ms
memory: 17160kb

Test #110:

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

Test #111:

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

Test #112:

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

Test #113:

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

Test #114:

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

Test #115:

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

Test #116:

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

Test #117:

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

Test #118:

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

Test #119:

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

Test #120:

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

Test #121:

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

Test #122:

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

Test #123:

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

Test #124:

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

Test #125:

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

Test #126:

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

Test #127:

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

Test #128:

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

Test #129:

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

Test #130:

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

Test #131:

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

Test #132:

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

Test #133:

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

Test #134:

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

Test #135:

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

Test #136:

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

Test #137:

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

Test #138:

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

Test #139:

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

Test #140:

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

Test #141:

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

Test #142:

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

Test #143:

score: 0
Accepted
time: 68ms
memory: 48708kb

Test #144:

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

Test #145:

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

Test #146:

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

Test #147:

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

Test #148:

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

Test #149:

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

Test #150:

score: 0
Accepted
time: 46ms
memory: 33224kb

Test #151:

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

Test #152:

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

Test #153:

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

Test #154:

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

Test #155:

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

Test #156:

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

Test #157:

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

Test #158:

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

Test #159:

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

Test #160:

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

Test #161:

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

Test #162:

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

Test #163:

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

Test #164:

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

Test #165:

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

Test #166:

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