# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1096191 | Sunbae | Putovanje (COCI20_putovanje) | C++17 | 50 ms | 41412 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>
typedef long long ll;
using namespace std;
const int N = 2e5 + 5, M = 4e5 + 5;
vector<int> g[N];
tuple<int,int,int,int> e[N];
int E[M], T[M], mn[N], ST[M][20], m;
ll d[N];
void dfs(int u){
E[m++] = u;
for(int v: g[u]){
g[v].erase(find(g[v].begin(), g[v].end(), u));
dfs(v); E[m++] = u;
}
}
int get_lca(int u, int v){
if(mn[u] > mn[v]) swap(u, v);
int j = 31 - __builtin_clz(mn[v] - mn[u] + 1);
return T[min(ST[mn[u]][j], ST[mn[v]-(1<<j)+1][j])];
}
void efs(int u){
for(int v: g[u]) efs(v), d[u] += d[v];
}
signed main(){
int n; scanf("%d", &n);
for(int i = 0, u, v, w[2]; i<n-1; ++i){
scanf("%d %d %d %d", &u, &v, w, w+1); --u; --v;
g[u].push_back(v); g[v].push_back(u);
e[i] = {u, v, w[0], w[1]};
}
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... |