# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
223201 | dwsc | Putovanje (COCI20_putovanje) | C++14 | 676 ms | 27128 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> ii;
typedef pair<ii,ii> iv;
vector<int> adj[200005];
int heavy[200005],depth[200005],head[200005], p[200005], pos[200005], sz[200005];
int cnt = 0; ///set to 1 if you're using fenwick tree
void dfs(int u){
sz[u] = 1;
int maxChild = 0;
for(int v : adj[u]){
if(sz[v] == 0){
depth[v] = depth[u] + 1;
dfs(v);
sz[u] += sz[v];
p[v] = u;
if(sz[v] > maxChild){
maxChild = sz[v];
heavy[u] = v;
}
}
}
}
void decompose(int u, int h){
head[u] = h;
pos[u] = cnt;
cnt++;
if(heavy[u] != 0) decompose(heavy[u], h);
for(int v : adj[u]){
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |