QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#731927#7075. Let's Play Jigsaw Puzzles!Yurily#WA 0ms25872kbC++201.4kb2024-11-10 12:18:472024-11-10 12:18:47

Judging History

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

  • [2024-11-10 12:18:47]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:25872kb
  • [2024-11-10 12:18:47]
  • 提交

answer

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

const int N = 1e3;

    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(){
    scanf("%d", &m);
    memset(p, 0, sizeof p);
    memset(v, 0, sizeof v);
    while(!q.empty())
        q.pop();
    for(int i = 1; i <= m * m; i++){
        for(int t = 0; t < 4; t++)
            scanf("%d", &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++)
            printf("%d ", id[x][y]);
        printf("\n");
    }

    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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 '