QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#731978#7075. Let's Play Jigsaw Puzzles!Yurily#RE 2ms7592kbC++201.1kb2024-11-10 12:35:312024-11-10 12:35:37

Judging History

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

  • [2024-11-10 12:35:37]
  • 评测
  • 测评结果:RE
  • 用时:2ms
  • 内存:7592kb
  • [2024-11-10 12:35:31]
  • 提交

answer

#include<iostream>
#include<cstring>
#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(){
    memset(id,0,sizeof id);
    memset(cnct,0,sizeof cnct);
    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++){
            if(j==m) cout<<id[i][j];
            else cout<<id[i][j]<<" ";
        }
        if(i!=m) cout<<"\n";
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 7592kb

input:

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

output:

1 2
3 4

result:

ok 2 lines

Test #2:

score: -100
Runtime Error

input:

42
1244 1713 1584 265
1100 1445 250 397
108 1161 26 940
1084 1119 1579 576
485 176 1251 781
917 1361 883 209
568 1162 44 368
1614 914 378 604
1059 687 1373 988
537 911 559 1649
1155 1685 352 1724
434 863 1367 298
963 41 1261 288
601 590 1554 1281
1714 -1 608 979
83 199 1072 1075
984 1411 1592 293
10...

output:


result: