QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#354344 | #7075. Let's Play Jigsaw Puzzles! | crsfaa# | WA | 1ms | 3840kb | C++14 | 936b | 2024-03-15 10:31:15 | 2024-03-15 10:31:16 |
Judging History
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]);
}
/*
3
1 2 3
4 5 6
7 8 9
3
-1 4 -1 2
-1 5 1 3
-1 6 2 -1
1 7 -1 5
2 8 4 6
3 9 5 -1
4 -1 -1 8
5 -1 7 9
6 -1 8 -1
*/
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++)
{
for(j=1;j<=m;j++)
printf("%d ",ans[i][j]);
if(i<m) puts("");
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3840kb
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 '