QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#731997#7075. Let's Play Jigsaw Puzzles!Yurily#WA 0ms11816kbC++201.5kb2024-11-10 12:40:522024-11-10 12:41:00

Judging History

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

  • [2024-11-10 12:41:00]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:11816kb
  • [2024-11-10 12:40:52]
  • 提交

answer

#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
using namespace std;

const int N = 5e3;

    int m;
    int p[N * N + 3][4];        //n, s, w, e
    queue<int>q;
    bool v[N * N + 3];
    int id[N + 3][N + 3];
    int fx[N * N + 3], fy[N * N + 3];

int main(){
//    freopen("in.txt", "r", stdin);
 //   freopen("out.txt", "w", stdout);
    ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);

    cin>>m;

    while(!q.empty())
        q.pop();
    for(int i = 1; i <= m * m; i++){
        for(int t = 0; t < 4; t++)
           cin>>p[i][t];
        if(p[i][0] == -1 && p[i][2] == -1){
            id[1][1] = i;
            v[i] = true;
            fx[i] = fy[i] = 1;
            q.push(i);
        }
    }

    while(!q.empty()){
        int i = q.front();
        q.pop();

        int x = fx[i], y = fy[i];
        int j;

        j = p[i][3];
        if(j != -1 && !v[j]){
            v[j] = true;
            q.push(j);
            id[x][y + 1] = j;
            fx[j] = x;
            fy[j] = y + 1;
        }

        j = p[i][1];
        if(j != -1 && !v[j]){
            v[j] = true;
            q.push(j);
            id[x + 1][y] = j;
            fx[j] = x + 1;
            fy[j] = y;
        }

    }

    for(int x = 1; x <= m; x++){
        for(int y = 1; y <= m; y++)
            cout<<id[x][y]<<" ";
        cout<<"\n";
    }

    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 11816kb

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 '