Codeforces Round #425 (Div. 2), problem: (D) Misha, Grisha and Underground Solution In C/C++

By |2017-07-25T01:18:21+00:00July 25th, 2017|Categories: C/C++, Programming|Tags: , , , , , , , , |

#include<cstdio> #include<iostream> using namespace std; struct Edge{ int to,next; }e[202020]; int head[101010],cnt=0; void add(int u,int v) { cnt++; e[cnt].to=v; e[cnt].next=head[u]; head[u]=cnt; } int anc[20][101010]; int dep[101010]; void dfs(int x,int fa) { for(int i=head[x];i!=0;i=e[i].next) { int to=e[i].to; if(to!=fa) { dep[to]=dep[x]+1; anc[0][to]=x; dfs(to,x); } } } [...]