Codecraft-17 and Codeforces Round #391 (Div. 1 + Div. 2, combined), problem: (G) Can Bash Save the Day? Solution in C/C++

By | 2017-04-07T22:10:19+00:00 January 16th, 2017|Categories: C/C++, Programming|Tags: , , , , , , , |

#include<bits/stdc++.h> #define N 200100 using namespace std; int sz[N]; vector<int> g[N],w[N]; int loc[N][20],dep[N],tloc[20],td; long long len[N][20]; bool del[N]; void build(int u, int p, int ly, long long d){ sz[u]=1; len[u][ly]=d; for(int i=0;i<g[u].size();i++){ int v=g[u][i]; if(v==p||del[v]) continue; build(v,u,ly,d+w[u][i]); sz[u]+=sz[v]; } } void decom(int u){ build(u,0,td,0); [...]