53992023-05-12 15:51:37szilSzéfnyitáscpp14Wrong answer 0/1008ms6296 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;
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Wrong answer3ms1832 KiB
2Wrong answer3ms2056 KiB
subtask20/16
3Wrong answer3ms2056 KiB
4Wrong answer3ms2268 KiB
5Wrong answer3ms2484 KiB
6Wrong answer3ms2676 KiB
7Wrong answer3ms2884 KiB
8Wrong answer2ms2976 KiB
9Wrong answer3ms3108 KiB
10Wrong answer2ms3188 KiB
11Wrong answer3ms3192 KiB
12Wrong answer3ms3188 KiB
13Wrong answer3ms3192 KiB
14Wrong answer3ms3192 KiB
subtask30/24
15Wrong answer3ms3192 KiB
16Wrong answer3ms3460 KiB
17Wrong answer3ms3688 KiB
18Wrong answer3ms3640 KiB
19Wrong answer3ms3832 KiB
20Wrong answer3ms3896 KiB
21Wrong answer3ms4044 KiB
22Wrong answer3ms4228 KiB
23Wrong answer3ms4500 KiB
subtask40/23
24Wrong answer3ms4500 KiB
25Wrong answer3ms4552 KiB
26Wrong answer3ms4532 KiB
27Wrong answer3ms4604 KiB
28Wrong answer3ms4548 KiB
29Wrong answer3ms4544 KiB
30Wrong answer3ms4540 KiB
31Wrong answer3ms4540 KiB
32Wrong answer3ms4688 KiB
subtask50/37
33Wrong answer3ms4688 KiB
34Wrong answer3ms2268 KiB
35Wrong answer3ms2484 KiB
36Wrong answer3ms2676 KiB
37Wrong answer3ms2884 KiB
38Wrong answer2ms2976 KiB
39Wrong answer3ms3108 KiB
40Wrong answer2ms3188 KiB
41Wrong answer3ms3192 KiB
42Wrong answer3ms3188 KiB
43Wrong answer3ms3192 KiB
44Wrong answer3ms3192 KiB
45Wrong answer3ms3460 KiB
46Wrong answer3ms3688 KiB
47Wrong answer3ms3640 KiB
48Wrong answer3ms3832 KiB
49Wrong answer3ms3896 KiB
50Wrong answer3ms4044 KiB
51Wrong answer3ms4228 KiB
52Wrong answer3ms4500 KiB
53Wrong answer3ms4552 KiB
54Wrong answer3ms4532 KiB
55Wrong answer3ms4604 KiB
56Wrong answer3ms4548 KiB
57Wrong answer3ms4544 KiB
58Wrong answer3ms4540 KiB
59Wrong answer3ms4540 KiB
60Wrong answer3ms4688 KiB
61Wrong answer3ms4468 KiB
62Wrong answer3ms4540 KiB
63Wrong answer3ms4580 KiB
64Wrong answer3ms4520 KiB
65Wrong answer7ms5756 KiB
66Wrong answer8ms5868 KiB
67Wrong answer7ms5688 KiB
68Wrong answer7ms5892 KiB
69Wrong answer7ms6108 KiB
70Wrong answer8ms6276 KiB
71Wrong answer7ms6296 KiB
72Wrong answer6ms6072 KiB