Submission #362880

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
3628802021-02-04 14:50:58David_MRace (IOI11_race)C++17
100 / 100
487 ms79212 KiB
#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];
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Compilation message (stderr)

race.cpp: In function 'void solve(int, int)':
race.cpp:27:11: warning: 'Y' may be used uninitialized in this function [-Wmaybe-uninitialized]
   27 |   if(y==pa||y==Y)continue;
      |      ~~~~~^~~~~~
race.cpp:23:18: warning: 'D' may be used uninitialized in this function [-Wmaybe-uninitialized]
   23 |  else z1[x]=z1[Y]+D, z2[x]=z2[Y]+1, e[x]=e[Y];
      |             ~~~~~^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...