摘要:
这个题搞的我好纠结呀!一直是WA,后来才知道自己记录的时候搞错了,ans应该为-1而不是0,因为当时同一个点时,距离为0;这里要用到LCA,我们的距离为两个子节点到根的距离和减去最近祖先的距离的2倍;#include<cstdio>#include<iostream>#include<string.h>#include<vector>using namespace std;class node{public: int en; int len; };vector<node>tree[10024],Qes[10024];int dist[ 阅读全文
posted @ 2012-01-08 14:01
wutaoKeen
阅读(355)
评论(0)
推荐(0)

浙公网安备 33010602011771号