QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#682427 | #7075. Let's Play Jigsaw Puzzles! | Nanami | WA | 0ms | 19492kb | C++17 | 1.3kb | 2024-10-27 15:24:39 | 2024-10-27 15:24:39 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const int N = 2010;
int a[N][N];
struct Node {
int s, x, z, y;
}e[N];
bool b[N];
int S, X, Z, Y;
int n;
void dfs(int x, int i, int j) {
if(b[x]) return;
b[x] = 1;
if(e[x].s != -1 && !b[e[x].s]) {
a[i - 1][j] = e[x].s;
S = min(S, i - 1);
dfs(e[x].s, i - 1, j);
}
if(e[x].x != -1 && !b[e[x].x]) {
a[i + 1][j] = e[x].x;
// cout << a[i + 1][j] << endl;
X = max(X, i + 1);
dfs(e[x].x, i + 1, j);
}
if(e[x].z != -1 && !b[e[x].z]) {
a[i][j - 1] = e[x].z;
Z = min(Z, j - 1);
dfs(e[x].z, i, j - 1);
}
if(e[x].y != -1 && !b[e[x].y]) {
a[i][j + 1] = e[x].y;
Y = max(Y, j + 1);
dfs(e[x].y, i, j + 1);
}
}
int main() {
memset(a, -1, sizeof a);
memset(b, 0, sizeof b);
X = S = Z = Y = 1001;
cin >> n;
for(int i = 1; i <= n; i ++)
cin >> e[i].s >> e[i].x >> e[i].z >> e[i].y;
// a[1001][1001] = 1;
dfs(1, 1001, 1001);
// cout << S << " " << X << " " << Z << " " << Y << endl;
a[1001][1001] = 1;
for(int i = S; i <= X; i ++) {
for(int j = Z; j <= Y; j ++)
cout << a[i][j] << (j == Y ? "\n" : " ");
// cout << endl;
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 19460kb
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
Wrong Answer
time: 0ms
memory: 19492kb
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:
-1 0 -1 -1 1244 -1 1584 1 265 -1 1713 -1
result:
wrong answer 1st lines differ - expected: '1559 1618 550 492 198 145 1622...89 621 1736 1478 1221 1507 1316', found: '-1 0 -1'