QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#731997 | #7075. Let's Play Jigsaw Puzzles! | Yurily# | WA | 0ms | 11816kb | C++20 | 1.5kb | 2024-11-10 12:40:52 | 2024-11-10 12:41:00 |
Judging History
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;
}
详细
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 '