QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#42846#4432. Jungle Trailfecto_elfilisRE 0ms0kbC++1.4kb2022-08-04 12:21:332022-08-04 12:21:36

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-08-04 12:21:36]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2022-08-04 12:21:33]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
const int N=2010;
int t,n,m,r[N],c[N],ans[N*2],nx[N][N],mp[N][N];
char s[N];
int main () {
	scanf("%d",&t);
	for (int ii=1;ii<=t;ii++) {
		scanf("%d%d",&n,&m);
		for (int i=1;i<=n;i++) {r[i]=0;}
		for (int i=1;i<=m;i++) {c[i]=0;}
		for (int i=1;i<=n+m-2;i++) {ans[i]=0;}
		for (int i=1;i<=n;i++) {
			scanf("%s",s+1);
			for (int j=1;j<=m;j++) {nx[i][j]=-1,mp[i][j]=(s[j]=='.'?0:(s[j]=='#'?1:(s[j]=='O'?2:3)));}
		}
		for (int i=n;i>=1;i--) {
			for (int j=m;j>=1;j--) {
				if (i==n&&j==m) {nx[i][j]=0;}
				else if (mp[i][j]!=1) {
					if (i<n&&nx[i+1][j]>=0) {nx[i][j]=i+1;}
					if (j<m&&nx[i][j+1]>=0) {nx[i][j]=j+1+n;}
				}
			}
		}
		if (!nx[1][1]) {printf("NIE\n");return 0;}
		int curx=1,cury=1,cnt=0;
		if (mp[1][1]==3) {r[1]=1;}
		while (curx!=n||cury!=m) {
			if (nx[curx][cury]<=n) {
				curx++;
				if ((mp[curx][cury]==3&&!c[cury])||(mp[curx][cury]==2&&c[cury])) {r[curx]=1;}
				ans[++cnt]=1;
			} else {
				cury++;
				if ((mp[curx][cury]==3&&!r[curx])||(mp[curx][cury]==2&&r[curx])) {c[cury]=1;}
				ans[++cnt]=0;
			}
		}
		printf("TAK\n");
		for (int i=1;i<=n;i++) {printf("%c",r[i]?'T':'N');}
		putchar('\n');
		for (int i=1;i<=m;i++) {printf("%c",c[i]?'T':'N');}
		putchar('\n');
		for (int i=1;i<=cnt;i++) {printf("%c",ans[i]?'D':'R');}
		putchar('\n');
	}
	return 0;
}

详细

Test #1:

score: 0
Runtime Error

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:


result: