QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#731942 | #7075. Let's Play Jigsaw Puzzles! | Yurily# | WA | 0ms | 3532kb | C++20 | 1009b | 2024-11-10 12:23:28 | 2024-11-10 12:23:29 |
Judging History
answer
#include<iostream>
#include<queue>
#define N 1010
using namespace std;
int m,cnct[N][4];
int id[N][N];
struct node{
int i,x,y;
};
queue<node> q;
void bfs(){
while(!q.empty()){
int i=q.front().i,x=q.front().x,y=q.front().y;
if(cnct[i][1]!=-1&&cnct[i][2]==-1){
id[x+1][y]=cnct[i][1];
node tmp={cnct[i][1],x+1,y};
q.push(tmp);
}
if(cnct[i][3]!=-1){
id[x][y+1]=cnct[i][3];
node tmp={cnct[i][3],x,y+1};
q.push(tmp);
}
q.pop();
}
}
int main(){
cin>>m;
for(int i=1;i<=m*m;i++){
for(int t=0;t<4;t++){
cin>>cnct[i][t];
}
if(cnct[i][0]==-1&&cnct[i][2]==-1){
node tmp={i,1,1};
id[1][1]=i;
q.push(tmp);
}
}
bfs();
for(int i=1;i<=m;i++){
for(int j=1;j<=m;j++){
cout<<id[i][j]<<" ";
}
cout<<"\n";
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3532kb
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 '