POJ1741 Tree(树的点分治基础题)】的更多相关文章

1 /* *********************************************** 2 Author :kuangbin 3 Created Time :2013-11-17 14:30:29 4 File Name :E:\2013ACM\专题学习\树的分治\POJ1741.cpp 5 ************************************************ */ 6 7 #include <stdio.h> 8 #include <str…
Give a tree with n vertices,each edge has a length(positive integer less than 1001).Define dist(u,v)=The min distance between node u and v. Give an integer k,for every pair (u,v) of vertices is called valid if and only if dist(u,v) not exceed k. Writ…
题目描述 Give a tree with n vertices,each edge has a length(positive integer less than 1001). Define dist(u,v)=The min distance between node u and v. Give an integer k,for every pair (u,v) of vertices is called valid if and only if dist(u,v) not exceed k…
D Tree Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 102400/102400 K (Java/Others) Total Submission(s): 1687    Accepted Submission(s): 263 Problem Description There is a skyscraping tree standing on the playground of Nanjing University of…
Tree Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 21357   Accepted: 7006 Description Give a tree with n vertices,each edge has a length(positive integer less than 1001).Define dist(u,v)=The min distance between node u and v.Give an in…
Description Give a tree with n vertices,each edge has a length(positive integer less than 1001). Define dist(u,v)=The min distance between node u and v. Give an integer k,for every pair (u,v) of vertices is called valid if and only if dist(u,v) not e…
http://poj.org/problem?id=1741   题意:一棵n个点的树,每条边有距离v,求该树中距离小于等于k的点的对数.   dis[y]表示点y到根x的距离,v代表根到子树根的距离: 那么不在同一棵子树中的两点i.j之间的距离为dis[i]+dis[j]: ①    设得到这个距离的时间复杂度为O(w): 如果我们层层如此递归即可得到所有的点对数量,可以证明复杂度为O(logn*w);   因为n的范围为(n<=10000)所以我们需要w与n近似:   那么此时问题转化为了如…
Tree   Description Give a tree with n vertices,each edge has a length(positive integer less than 1001). Define dist(u,v)=The min distance between node u and v. Give an integer k,for every pair (u,v) of vertices is called valid if and only if dist(u,v…
题目链接:poj1741_Tree 题意: 给你一颗n个节点的树,每条边有一个值,问有多少点对(u,v),满足u->v的最短路径小于k. 题解: 典型的树的分治,板子题. #include<cstdio> #include<algorithm> #include<cstring> #define F(i,a,b) for(int i=a;i<=b;++i) using namespace std; ; ],nxt[N*],w[N*],ed,ans; int…
Tree Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 23380   Accepted: 7748 Description Give a tree with n vertices,each edge has a length(positive integer less than 1001). Define dist(u,v)=The min distance between node u and v. Give an…