Description
A tree, asking for distance between two points.
Sol
Double.
The direction is useless.
No, then.
Code
/************************************************************** problem:3364 User:beiyu language:c++ Result : Accepted time:400 ms memory:11556 kb****************************************************************/#include < cstdio> #include <utility> #include <vector> #include <iostream>using namespace std; #define MPR make_pairtypedef pair< int,int > pr;const int N = 40005;const int M = 20; int n,m,k;vector<pr> h[n];bool b[n];int pow2[m],d[n];int f[n][m],g[n][m]; inline int in (int x=0,char Ch=getchar ()) {while (ch> ' 9 ' | | ch< ' 0 ') Ch=getchar (); while (ch>= ' 0 ' && ch<= ' 9 ') x= (x<<3) + (x<<1) +ch-' 0 ', Ch=getchar (); return x; }void DFS (int u,int fa) {b[u]=1,d[u]=d[fa]+1; for (int i=0,v;i
Bzoj 3364: [Usaco2004 feb]distance Queries Distance Consulting