QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#676980#7699. Pearlsnew_game_plus_players#WA 0ms3876kbC++142.4kb2024-10-26 08:03:142024-10-26 08:03:15

Judging History

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

  • [2024-10-26 08:03:15]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3876kb
  • [2024-10-26 08:03:14]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int MAXN = 65;
const int dx[4] = {0, -1, 1,  0};
const int dy[4] = {1,  0, 0, -1};
const char ch[4] = {'E', 'N', 'S', 'W'};
int tot, n, m, sx, sy;
char s[MAXN], ret[MAXN];
int vis[MAXN][MAXN];
void work(int depth, int x, int y, int flg) { // flg: 0 -> no limit, 1 -> straight, 2 -> turn
	int steps = tot + 1 - depth;
	if (steps < abs(x - sx) + abs(y - sy)) return;
	if (depth > tot) {
		if (flg == 1 && ret[tot] != ret[1]) return;
		if (flg == 2 && ret[tot] == ret[1]) return;
		
		if (s[1] == 'B' && ret[tot] != ret[tot - 1]) return;
		if (s[1] == 'W' && ret[tot] == ret[tot - 1]) return;

		if (s[2] == 'B' && ret[tot] != ret[1]) return;
		if (s[1] == 'W' && !(ret[2] != ret[1] || ret[tot] != ret[tot - 1])) return;
		if (s[2] == 'W' && !(ret[3] != ret[2] || ret[1] != ret[tot])) return;
		
		printf("%s\n", ret + 1);
		exit(0);
		return;
	}
	if (x < 1 || x > n || y < 1 || y > m || vis[x][y]) return;
	vis[x][y] = depth;
	if (depth == 1) {
		for (int i = 0; i <= 3; i++) {
			ret[depth] = ch[i];
			work(depth + 1, x + dx[i], y + dy[i], 0);
		}
		vis[x][y] = 0;
		return;
	}
	if (s[depth] == 'B') {
		if (flg == 1 || (depth >= 3 && ret[depth - 2] != ret[depth - 1])) {
			vis[x][y] = 0;
			return;
		}
		for (int i = 0; i <= 3; i++) {
			if (ch[i] == ret[depth - 1]) continue;
			ret[depth] = ch[i];
			work(depth + 1, x + dx[i], y + dy[i], 1);
		}
		vis[x][y] = 0;
		return;
	}
	if (s[depth] == 'W') {
		if (flg == 2) {
			vis[x][y] = 0;
			return;
		}
		for (int i = 0; i <= 3; i++) {
			if (ch[i] != ret[depth - 1]) continue;
			ret[depth] = ch[i];
			work(depth + 1, x + dx[i], y + dy[i], 2 * (depth >= 3 && ret[depth - 1] == ret[depth - 2]));
		}
		vis[x][y] = 0;
		return;
	}
	if (s[depth] == '.') {
		if (flg == 0) {
			for (int i = 0; i <= 3; i++) {
				ret[depth] = ch[i];
				work(depth + 1, x + dx[i], y + dy[i], 0);
			}
		} else if (flg == 1) {
			for (int i = 0; i <= 3; i++) {
				if (ch[i] != ret[depth - 1]) continue;
				ret[depth] = ch[i];
				work(depth + 1, x + dx[i], y + dy[i], 0);
			}
		} else {
			for (int i = 0; i <= 3; i++) {
				if (ch[i] == ret[depth - 1]) continue;
				ret[depth] = ch[i];
				work(depth + 1, x + dx[i], y + dy[i], 0);
			}
		}
		vis[x][y] = 0;
		return;
	}
}
int main() {
	scanf("%d%d%d", &tot, &n, &m);
	scanf("\n%s", s + 1);
	scanf("%d%d", &sx, &sy);
	work(1, sx, sy, 0);
	puts("impossible");
	return 0;
}

详细

Test #1:

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

input:

16 5 6
B.B.B.BW.WB..WB.
3 1

output:

EENNEESSSSWWWWNN

result:

ok single line: 'EENNEESSSSWWWWNN'

Test #2:

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

input:

6 5 5
W..B.B
3 3

output:

impossible

result:

ok single line: 'impossible'

Test #3:

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

input:

8 5 5
B.B.B.B.
5 5

output:

NNWWSSEE

result:

ok single line: 'NNWWSSEE'

Test #4:

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

input:

8 10 10
B.BWBWB.
2 10

output:

SSWWNNEE

result:

ok single line: 'SSWWNNEE'

Test #5:

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

input:

10 5 10
W.B.BW.B.B
4 4

output:

EENNWWWSSE

result:

ok single line: 'EENNWWWSSE'

Test #6:

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

input:

10 10 10
B.B.B.B.B.
7 3

output:

impossible

result:

ok single line: 'impossible'

Test #7:

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

input:

12 10 10
B.B.B.B.B.B.
10 1

output:

impossible

result:

ok single line: 'impossible'

Test #8:

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

input:

16 15 15
B.B.B.B.B.B.B.B.
4 4

output:

impossible

result:

ok single line: 'impossible'

Test #9:

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

input:

24 20 20
B.B.B.B.B.B.B.B.B.B.B.B.
1 8

output:

EESSEESSWWSSWWNNWWNNEENN

result:

ok single line: 'EESSEESSWWSSWWNNWWNNEENN'

Test #10:

score: -100
Wrong Answer
time: 0ms
memory: 3812kb

input:

60 50 50
B.B.B.B.B.B.BWB.B.B.B..B.B.B.B.BWB.B.B.B.B.B.B.B.B.B.B.B.B..
10 10

output:

EENNEENNEENNEENNEESSEEESSWWSSWWNNWWSSWWSSWWSSWWSSWWNNWWNNEEE

result:

wrong answer 1st lines differ - expected: 'impossible', found: 'EENNEENNEENNEENNEESSEEESSWWSSWWNNWWSSWWSSWWSSWWSSWWNNWWNNEEE'