QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#395463 | #7075. Let's Play Jigsaw Puzzles! | suibian_xiaozhao# | WA | 0ms | 3480kb | C++23 | 1.3kb | 2024-04-21 15:01:22 | 2024-04-21 15:01:24 |
Judging History
answer
//
// Created by DELLPC on 24-4-21.
//
#include<bits/stdc++.h>
using namespace std;
struct op {
int n, s, w, e;
};
int main() {
ios::sync_with_stdio(0), cin.tie(0);
int m;
cin >> m;
vector<op> ops(m * m + 1);
int st, num;
vector<int> nn(m * m + 1), ww(m * m + 1), cnt(m * m + 1);
for (int i = 1; i <= m * m; i++) {
cin >> ops[i].n >> ops[i].s >> ops[i].w >> ops[i].e;
if (ops[i].s != -1)
cnt[ops[i].s]++;
if (ops[i].e != -1)
cnt[ops[i].e]++;
if (ops[i].n == -1 && ops[i].w == -1)
st = i;
if (ops[i].n != -1)
nn[ops[i].n] = i;
if (ops[i].w != -1)
ww[ops[i].w] = i;
}
for (int i = 1; i <= m * m; i++) {
if (cnt[i] == 0) {
num = i;
}
}
while (1) {
int now1 = num, now2 = st;
while (1) {
cout << now1 << ' ';
int t = ops[now2].e;
if (t == -1) {
break;
}
now2 = ww[now1];
now1 = t;
}
cout << "\n";
int t = ops[st].s;
if (t == -1) {
break;
}
st = nn[num];
num = t;
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3480kb
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 '