Submission #1245550

#TimeUsernameProblemLanguageResultExecution timeMemory
1245550franuchTree (IOI24_tree)C++20
0 / 100
52 ms16540 KiB
#include "tree.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
#define vc vector
#define st first
#define nd second
#define all(a) a.begin(), a.end()
#define sz(a) (ll)a.size()
#define pub push_back
#define pob pop_back
const ll INF = 1e18;

ll V;
vc<ll> par, wgh;
vc<vc<ll>> g;

ll x = 0;

void init(vc<int> P, vc<int> W) {
        par.assign(all(P));
        wgh.assign(all(W));
        V = sz(par);
        g.assign(V, vc<ll>());
        for (ll v = 1; v < V; v++)
                g[par[v]].pub(v);

        for (ll v = 0; v < V; v++)
                x += abs(sz(g[v]) - 1);
}

ll query(int _L, int _R) {
        ll L = _L;
        ll R = _R;
        return x * L - (R - L);
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...