5399 | 2023-05-12 15:51:37 | szil | Széfnyitás | cpp14 | Wrong answer 0/100 | 8ms | 6296 KiB |
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
const ll INF = 1e18;
const int MAXN = 151;
int a[MAXN];
int s[MAXN], s2[50001][2];
int timer;
struct Node {
Node *p[2] = {nullptr, nullptr};
int u = -1, t;
};
Node *root;
void add(vector<int> &v, int u) {
Node *ptr = root;
for (int i : v) {
if (ptr->p[i] == nullptr) {
ptr->p[i] = new Node();
ptr->p[i]->t = timer++;
}
ptr = ptr->p[i];
}
ptr->u = u;
}
void upd(Node *v) {
if (v->u != -1) {
s2[v->t][0] = s2[v->t][1] = v->u;
return;
}
if (v->p[0] != nullptr) {
s2[v->t][0] = v->p[0]->t;
upd(v->p[0]);
}
if (v->p[1] != nullptr) {
s2[v->t][1] = v->p[1]->t;
upd(v->p[1]);
}
}
int main()
{
srand(time(0));
ios::sync_with_stdio(0); cin.tie(0);
int n, k; cin >> n;
timer = n + 1;
root = new Node();
root->t = timer++;
for (int i = 1; i <= n; i++) {
int x;
cin >> a[i] >> s[i] >> x;
}
cin >> k;
for (int i = 1; i <= n; i++) {
vector<int> v;
int u = i;
for (int it = 0; it < n-1; it++) {
v.push_back(a[u]);
u = s[u];
}
add(v, s[u]);
}
upd(root);
cout << timer-1 << " " << n+1 << "\n";
for (int i = 1; i <= n; i++) {
cout << a[i] << " " << s[i] << " " << s[i] << "\n";
}
for (int i = n+1; i < timer; i++) {
cout << (rand() % 2) << " " << s2[i][0] << " " << s2[i][1] << "\n";
}
return 0;
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Wrong answer | 3ms | 1832 KiB | ||||
2 | Wrong answer | 3ms | 2056 KiB | ||||
subtask2 | 0/16 | ||||||
3 | Wrong answer | 3ms | 2056 KiB | ||||
4 | Wrong answer | 3ms | 2268 KiB | ||||
5 | Wrong answer | 3ms | 2484 KiB | ||||
6 | Wrong answer | 3ms | 2676 KiB | ||||
7 | Wrong answer | 3ms | 2884 KiB | ||||
8 | Wrong answer | 2ms | 2976 KiB | ||||
9 | Wrong answer | 3ms | 3108 KiB | ||||
10 | Wrong answer | 2ms | 3188 KiB | ||||
11 | Wrong answer | 3ms | 3192 KiB | ||||
12 | Wrong answer | 3ms | 3188 KiB | ||||
13 | Wrong answer | 3ms | 3192 KiB | ||||
14 | Wrong answer | 3ms | 3192 KiB | ||||
subtask3 | 0/24 | ||||||
15 | Wrong answer | 3ms | 3192 KiB | ||||
16 | Wrong answer | 3ms | 3460 KiB | ||||
17 | Wrong answer | 3ms | 3688 KiB | ||||
18 | Wrong answer | 3ms | 3640 KiB | ||||
19 | Wrong answer | 3ms | 3832 KiB | ||||
20 | Wrong answer | 3ms | 3896 KiB | ||||
21 | Wrong answer | 3ms | 4044 KiB | ||||
22 | Wrong answer | 3ms | 4228 KiB | ||||
23 | Wrong answer | 3ms | 4500 KiB | ||||
subtask4 | 0/23 | ||||||
24 | Wrong answer | 3ms | 4500 KiB | ||||
25 | Wrong answer | 3ms | 4552 KiB | ||||
26 | Wrong answer | 3ms | 4532 KiB | ||||
27 | Wrong answer | 3ms | 4604 KiB | ||||
28 | Wrong answer | 3ms | 4548 KiB | ||||
29 | Wrong answer | 3ms | 4544 KiB | ||||
30 | Wrong answer | 3ms | 4540 KiB | ||||
31 | Wrong answer | 3ms | 4540 KiB | ||||
32 | Wrong answer | 3ms | 4688 KiB | ||||
subtask5 | 0/37 | ||||||
33 | Wrong answer | 3ms | 4688 KiB | ||||
34 | Wrong answer | 3ms | 2268 KiB | ||||
35 | Wrong answer | 3ms | 2484 KiB | ||||
36 | Wrong answer | 3ms | 2676 KiB | ||||
37 | Wrong answer | 3ms | 2884 KiB | ||||
38 | Wrong answer | 2ms | 2976 KiB | ||||
39 | Wrong answer | 3ms | 3108 KiB | ||||
40 | Wrong answer | 2ms | 3188 KiB | ||||
41 | Wrong answer | 3ms | 3192 KiB | ||||
42 | Wrong answer | 3ms | 3188 KiB | ||||
43 | Wrong answer | 3ms | 3192 KiB | ||||
44 | Wrong answer | 3ms | 3192 KiB | ||||
45 | Wrong answer | 3ms | 3460 KiB | ||||
46 | Wrong answer | 3ms | 3688 KiB | ||||
47 | Wrong answer | 3ms | 3640 KiB | ||||
48 | Wrong answer | 3ms | 3832 KiB | ||||
49 | Wrong answer | 3ms | 3896 KiB | ||||
50 | Wrong answer | 3ms | 4044 KiB | ||||
51 | Wrong answer | 3ms | 4228 KiB | ||||
52 | Wrong answer | 3ms | 4500 KiB | ||||
53 | Wrong answer | 3ms | 4552 KiB | ||||
54 | Wrong answer | 3ms | 4532 KiB | ||||
55 | Wrong answer | 3ms | 4604 KiB | ||||
56 | Wrong answer | 3ms | 4548 KiB | ||||
57 | Wrong answer | 3ms | 4544 KiB | ||||
58 | Wrong answer | 3ms | 4540 KiB | ||||
59 | Wrong answer | 3ms | 4540 KiB | ||||
60 | Wrong answer | 3ms | 4688 KiB | ||||
61 | Wrong answer | 3ms | 4468 KiB | ||||
62 | Wrong answer | 3ms | 4540 KiB | ||||
63 | Wrong answer | 3ms | 4580 KiB | ||||
64 | Wrong answer | 3ms | 4520 KiB | ||||
65 | Wrong answer | 7ms | 5756 KiB | ||||
66 | Wrong answer | 8ms | 5868 KiB | ||||
67 | Wrong answer | 7ms | 5688 KiB | ||||
68 | Wrong answer | 7ms | 5892 KiB | ||||
69 | Wrong answer | 7ms | 6108 KiB | ||||
70 | Wrong answer | 8ms | 6276 KiB | ||||
71 | Wrong answer | 7ms | 6296 KiB | ||||
72 | Wrong answer | 6ms | 6072 KiB |