# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
362880 | David_M | Race (IOI11_race) | C++17 | 487 ms | 79212 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 "race.h"
#include<bits/stdc++.h>
using namespace std;
const int N=200005;
int sz[N], e[N], z1[N], z2[N], o, k, K, Ans=N;
vector <pair<int, int> > v[N];
map<int, int> m[N];
void solve(int x=0, int pa=0){
sz[x]=1;
int mx=0, Y, D;
for (auto [y,d]:v[x]){
if(y==pa)continue;
solve(y, x);
sz[x]+=sz[y];
if(sz[y]>mx) mx=sz[y], Y=y, D=d;
}
if(sz[x]==1) e[x]=o++;
else z1[x]=z1[Y]+D, z2[x]=z2[Y]+1, e[x]=e[Y];
m[e[x]][0-z1[x]]=0-z2[x];
for (auto [y,d]:v[x]){
if(y==pa||y==Y)continue;
for(auto [kk,ans]:m[e[y]]){
k=kk+d+z1[y]+z1[x];
ans+=1+z2[y]+z2[x];
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... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |