QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#682420 | #7075. Let's Play Jigsaw Puzzles! | Nanami | WA | 3ms | 19472kb | C++17 | 1.3kb | 2024-10-27 15:23:29 | 2024-10-27 15:23:31 |
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] << " ";
cout << endl;
}
}
详细
Test #1:
score: 0
Wrong Answer
time: 3ms
memory: 19472kb
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 '