QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#354343#7075. Let's Play Jigsaw Puzzles!crsfaa#WA 1ms3800kbC++14782b2024-03-15 10:19:022024-03-15 10:19:04

Judging History

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

  • [2024-03-15 10:19:04]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3800kb
  • [2024-03-15 10:19:02]
  • 提交

answer

#include<bits/stdc++.h>
#define Yukinoshita namespace
#define Yukino std
using Yukinoshita Yukino;
int read()
{
	int s=0,w=1;
	char ch=getchar();
	while(ch<'0'||ch>'9') w=ch=='-'?-1:1,ch=getchar();
	while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
	return s*w;
}
const int fx[]={-1,1,0,0},fy[]={0,0,-1,1};
int a[1000005][4];
int ans[1005][1005];
void dfs(int d,int x,int y)
{
	if(ans[x][y]) return;
	ans[x][y]=d;
	for(int i=0;i<4;i++)
		if(a[d][i]!=-1)
			dfs(a[d][i],x+fx[i],y+fy[i]);
}
int main()
{
	int m=read(),i,j;
	for(i=1;i<=m*m;i++)
		for(j=0;j<4;j++)
			a[i][j]=read();
	for(i=1;i<=m*m;i++)
		if(a[i][0]==-1&&a[i][2]==-1)
		{
			dfs(i,1,1);
			break;
		}
	for(i=1;i<=m;i++,puts(""))
		for(j=1;j<=m;j++)
			printf("%d ",ans[i][j]);
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3800kb

input:

2
-1 3 -1 2
-1 4 1 -1
1 -1 -1 4
2 -1 3 -1

output:

1 2 
3 4 

result:

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