QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#100889#4432. Jungle Traillonytree#WA 618ms407148kbC++143.3kb2023-04-28 16:13:462023-04-28 16:13:48

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-04-28 16:13:48]
  • 评测
  • 测评结果:WA
  • 用时:618ms
  • 内存:407148kb
  • [2023-04-28 16:13:46]
  • 提交

answer

#include <bits/stdc++.h>
#define endl '\n'
using namespace std;
const int N = 2005;
int tt;
int n, m;
bool turn[2][N];
char c[N][N];
bool f[N][N][2][3];
array<int, 4> g[N][N][2][3];
char ans[N << 1];
//0: ÏÂ 1: ÓÒ
//ÊÇ·ñÓж¾Éß 1 2
void dfs(int x, int y, int p, int q, bool C){
	int val = c[x][y] == '.' ? 0 : (c[x][y] == 'O' ? 1 : 2);
	if (turn[0][x] ^ turn[1][y]) val = (3 - val) % 3;
	if (x == 1 && y == 1){
		if (val == 2)
			turn[ans[1] == 'D'][1] ^= 1;
		return;
	}
	ans[x + y - 2] = "DP"[p];
	if (val == 2){
		if (p ^ C) turn[1][y] ^= 1;
		else turn[0][x] ^= 1;
	}
	dfs(g[x][y][p][q][0], g[x][y][p][q][1], g[x][y][p][q][2], g[x][y][p][q][3], g[x][y][p][q][2] ^ p);
}
void solve(){
	cin >> n >> m;
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= m; j++){
			memset(f[i][j], 0, sizeof(f[i][j]));
			memset(g[i][j], 0, sizeof(g[i][j]));
		}
	for (int i = 1; i <= n; i++)
		turn[0][i] = 0;
	for (int i = 1; i <= m; i++)
		turn[1][i] = 0;
	for (int i = 1; i <= n; i++)
		cin >> (c[i] + 1);
	for (int i : {0, 1})
		for (int j : {0, 1, 2})
			f[1][1][i][j] = 1;
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= m; j++){
			if (c[i][j] == '#') continue;
			int val = c[i][j] == '.' ? 0 : (c[i][j] == 'O' ? 1 : 2);
			//ÏÂÏÂ
			if (i < n)
				for (int k : {0, 1, 2})
					if (f[i][j][0][k]){
						f[i + 1][j][0][k] = 1;
						g[i + 1][j][0][k] = array<int, 4>{i, j, 0, k};
					}
			//ÏÂÓÒ
			if (j < m){
				if (f[i][j][0][0]){
					f[i][j + 1][1][val] = 1;
					g[i][j + 1][1][val] = array<int, 4>{i, j, 0, 0};
				}
				if (f[i][j][0][1]){
					f[i][j + 1][1][val] = 1;
					g[i][j + 1][1][val] = array<int, 4>{i, j, 0, 1};
				}
				if (f[i][j][0][0]){
					f[i][j + 1][1][(3 - val) % 3] = 1;
					g[i][j + 1][1][(3 - val) % 3] = array<int, 4>{i, j, 0, 0};
				}
				if (f[i][j][0][2]){
					f[i][j + 1][1][(3 - val) % 3] = 1;
					g[i][j + 1][1][(3 - val) % 3] = array<int, 4>{i, j, 0, 2};
				}
			}
			//ÓÒÓÒ 
			if (j < m)
				for (int k : {0, 1, 2})
					if (f[i][j][1][k]){
						f[i][j + 1][1][k] = 1;
						g[i][j + 1][1][k] = array<int, 4>{i, j, 1, k};
					}
			//ÓÒÏÂ
			if (i < n){
				if (f[i][j][1][0]){
					f[i + 1][j][0][val] = 1;
					g[i + 1][j][0][val] = array<int, 4>{i, j, 1, 0};
				}
				if (f[i][j][1][1]){
					f[i + 1][j][0][val] = 1;
					g[i + 1][j][0][val] = array<int, 4>{i, j, 1, 1};
				}
				if (f[i][j][1][0]){
					f[i + 1][j][0][(3 - val) % 3] = 1;
					g[i + 1][j][0][(3 - val) % 3] = array<int, 4>{i, j, 1, 0};
				}
				if (f[i][j][1][2]){
					f[i + 1][j][0][(3 - val) % 3] = 1;
					g[i + 1][j][0][(3 - val) % 3] = array<int, 4>{i, j, 1, 2};
				}
			}
		}
	for (int p : {0, 1})
		for (int q : {0, 1, 2})
			if (f[n][m][p][q]){
				cout << "TAK" << endl;
				if (q) turn[p ^ 1][p ? n : m] ^= 1;
				dfs(n, m, p, q, 0);
				for (int i = 1; i <= n; i++)
					cout << "NT"[turn[0][i]];
				cout << endl;
				for (int i = 1; i <= m; i++)
					cout << "NT"[turn[1][i]];
				cout << endl;
				for (int i = 1; i <= n + m - 2; i++)
					cout << ans[i];
				cout << endl;
				return;
			}
	cout << "NIE" << endl;
}
int main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//	freopen("in.txt", "r", stdin);
//	freopen("out.txt", "w", stdout);
	cin >> tt;
	while (tt--) solve();
	return 0;
}

详细

Test #1:

score: 0
Wrong Answer
time: 618ms
memory: 407148kb

input:

486
4 5
..#..
@@O@@
##@#O
..@.@
2 2
OO
OO
2 2
@@
@@
2 2
@@
#@
2 2
@O
#@
2 2
@@
OO
2 2
O#
@O
2 2
@#
#@
2 2
@.
.@
2 2
@#
.O
2 2
OO
.O
10 10
@O@O#O@@@#
OO#@#@@#OO
#@#@#O##O@
OO##@@O#@O
O##@@#@O#@
OO@OO@@@O@
@O#@#@O#@O
@OOOOO@##.
O@OOO##O@@
OO@@OOOO#@
10 10
@@#OOO#O@@
#@@OO@@.O@
#.O@@O#@@O
OO@@#O@#O@
.#...

output:

TAK
NNTN
TTNTT
DPPPPDD
TAK
NT
NT
PD
TAK
TN
NT
PD
TAK
TN
NT
PD
TAK
TN
NT
PD
TAK
TT
NT
PD
TAK
NT
NT
DP
NIE
TAK
TT
NN
PD
TAK
NN
TN
DP
TAK
NT
NT
PD
NIE
TAK
TNNTNNNNTN
NTNNNTTNTT
PDDDPPDDDDPPDPPPPD
TAK
NNNNTNTTTT
NNNNTNTTNT
DDDDDPDDDPPPPPPPPD
TAK
NNTNTNNTTN
NTNNTNNTTN
DDDPPDPDDPPPPPPDDD
TAK
NNNTNNNTNT
NN...

result:

wrong answer you dead (test case 2)