QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#731831 | #7075. Let's Play Jigsaw Puzzles! | Yurily# | WA | 0ms | 23496kb | C++20 | 1.7kb | 2024-11-10 11:39:53 | 2024-11-10 11:39:54 |
Judging History
answer
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
const int N = 1e3;
int m;
int fx(int i){
return i / m + (i % m > 0);
}
int fy(int i){
return (i % m == 0)?m:(i % m);
}
int fi(int x, int y){
return (x - 1) * m + y;
}
int id[N + 3][N + 3];
int p[N * N + 3][4]; //n, s, w, e
bool v[N + 3];
int n, a[N + 3];
int main(){
scanf("%d", &m);
n = 0;
memset(p, 0, sizeof p);
for(int x = 1; x <= m; x++)
for(int y = 1; y <= m; y++){
int i = fi(x, y);
for(int t = 0; t < 4; t++)
scanf("%d", &p[i][t]);
if(p[i][0] == -1)
a[++n] = i;
}
// for(int x = 1; x <= m; x++){
// for(int y = 1; y <= m; y++){
// int i = fi(x, y);
// for(int t = 0; t < 4; t++)
// printf("%4d", p[i][t]);
// printf("\n");
// }
// }
memset(v, 0, sizeof v);
memset(id, 0, sizeof id);
for(int y = 1, j, i; y <= m && id[1][y] == 0; y++){
for(j = 1, i = a[j];j <= m; j++, i = a[j]){
if(v[j])
continue;
if(p[i][2] == -1){
id[1][y] = i;
v[j] = true;
p[p[i][3]][2] = -1;
break;
}
}
}
for(int y = 1; y <= m; y++)
printf("%d ", id[1][y]);
printf("\n");
for(int x = 2; x <= m; x++){
for(int y = 1; y <= m; y++){
id[x][y] = p[id[x - 1][y]][1];
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: 23496kb
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 '