
----树分治
文章平均质量分 86
_Occult_
物語が始まった
展开
-
ZOJ 3863 Paths on the Tree
DescriptionEdward has a tree with n vertices conveniently labeled with 1,2,…,n.Edward finds a pair of paths on the tree which share no more than k common vertices. Now Edward is interested in th原创 2016-05-10 22:36:21 · 1135 阅读 · 0 评论 -
POJ 1987 Distance Statistics
DescriptionFrustrated at the number of distance queries required to find a reasonable route for his cow marathon, FJ decides to ask queries from which he can learn more information. Specifically原创 2016-05-07 14:06:12 · 724 阅读 · 0 评论 -
HDU 4670 Cube number on a tree
DescriptionThe country Tom living in is famous for traveling. Every year, many tourists from all over the world have interests in traveling there. There are n provinces in the country. According原创 2016-05-07 21:37:59 · 599 阅读 · 0 评论 -
HYSBZ 4012 开店
Description 风见幽香有一个好朋友叫八云紫,她们经常一起看星星看月亮从诗词歌赋谈到人生哲学。最近她们灵机一动,打算在幻想乡开一家小店来做生意赚点钱。这样的想法当然非常好啦,但是她们也发现她们面临着一个问题,那就是店开在哪里,面向什么样的人群。很神奇的是,幻想乡的地图是一个树形结构,幻想乡一共有 n个地方,编号为 1 到 n,被 n-1 条带权的边连接起来。每个原创 2016-05-08 13:50:30 · 484 阅读 · 0 评论 -
HDU 4918 Query on the subtree
Descriptionbobo has a tree, whose vertices are conveniently labeled by 1,2,…,n. At the very begining, the i-th vertex is assigned with weight w i. There are q operations. Each operations are o原创 2016-05-08 23:30:14 · 2350 阅读 · 0 评论 -
HYSBZ 3672 购票
Description 今年夏天,NOI在SZ市迎来了她30周岁的生日。来自全国 n 个城市的OIer们都会从各地出发,到SZ市参加这次盛会。 全国的城市构成了一棵以SZ市为根的有根树,每个城市与它的父亲用道路连接。为了方便起见,我们将全国的n个城市用 1 到 n 的整数编号。其中SZ市的编号为 1。对于除SZ市之外的任意一个城市 v,我们给出了它在这棵树上的父亲城市原创 2016-06-02 15:50:32 · 427 阅读 · 0 评论 -
ZOJ 3937 More Health Points
DescriptionRecently, Bright Luna is playing a massively multiplayer online role-playing game (MMORPG) called Legendary Age. Designers of this game prepared many mini-games during daily operations.原创 2016-05-19 21:56:28 · 1244 阅读 · 0 评论 -
HDU 4812 D Tree
DescriptionThere is a skyscraping tree standing on the playground of Nanjing University of Science and Technology. On each branch of the tree is an integer (The tree can be treated as a connected原创 2016-05-06 16:36:10 · 827 阅读 · 0 评论 -
UVALive 7148 LRIP
2014年上海区域赛的K题,树上点分治,查找差值小于等于D的非严格单调序列的最长长度。对于每个点,维护从该点出发的上升序列同长度的最小值和下降序列的同长度最大值,二分之前的得到答案。#include#include#include#include#include#include#include#include#include#include#include#inclu原创 2016-10-26 20:02:32 · 340 阅读 · 0 评论 -
CodeChef PRIMEDST Prime Distance On Tree
DescriptionAll submissions for this problem are available.Problem description.You are given a tree. If we select 2 distinct nodes uniformly at random, what's the probability that the distance原创 2016-05-06 23:51:27 · 3494 阅读 · 0 评论 -
HYSBZ 4016 最短路径树问题
Description给一个包含n个点,m条边的无向连通图。从顶点1出发,往其余所有点分别走一次并返回。往某一个点走时,选择总长度最短的路径走。若有多条长度最短的路径,则选择经过的顶点序列字典序最小的那条路径(如路径A为1,32,11,路径B为1,3,2,11,路径B字典序较小。注意是序列的字典序的最小,而非路径中节点编号相连的字符串字典序最小)。到达该点后按原路返回,然后往其他点原创 2016-05-05 23:43:48 · 928 阅读 · 0 评论 -
HYSBZ 1758 重建计划
DescriptionInput第一行包含一个正整数N,表示X国的城市个数. 第二行包含两个正整数L和U,表示政策要求的第一期重建方案中修建道路数的上下限 接下来的N-1行描述重建小组的原有方案,每行三个正整数Ai,Bi,Vi分别表示道路(Ai,Bi),其价值为Vi 其中城市由1..N进行标号Output输出最大平均估值,保留三位小数原创 2016-05-16 21:40:35 · 446 阅读 · 0 评论 -
POJ 2114 Boatherds
DescriptionBoatherds Inc. is a sailing company operating in the country of Trabantustan and offering boat trips on Trabantian rivers. All the rivers originate somewhere in the mountains and on t原创 2016-05-10 22:37:50 · 874 阅读 · 0 评论 -
HDU 5016 Mart Master II
DescriptionTrader Dogy lives in city S, which consists of n districts. There are n - 1 bidirectional roads in city S, each connects a pair of districts. Indeed, city S is connected, i.e. people ca原创 2016-05-11 10:12:44 · 855 阅读 · 0 评论 -
CodeForces 293E Close Vertices
DescriptionYou've got a weighted tree, consisting of n vertices. Each edge has a non-negative weight. The length of the path between any two vertices of the tree is the number of edges in the path原创 2016-05-11 18:16:56 · 632 阅读 · 0 评论 -
SPOJ FTOUR2 Free tour II
DescriptionAfter the success of 2nd anniversary (take a look at problem FTOUR for more details), this 3rd year, Travel Agent SPOJ goes on with another discount tour.The tour will be held on IC原创 2016-05-11 19:45:28 · 1061 阅读 · 0 评论 -
HYSBZ 1095 Hide 捉迷藏
Description 捉迷藏 Jiajia和Wind是一对恩爱的夫妻,并且他们有很多孩子。某天,Jiajia、Wind和孩子们决定在家里玩捉迷藏游戏。他们的家很大且构造很奇特,由N个屋子和N-1条双向走廊组成,这N-1条走廊的分布使得任意两个屋子都互相可达。游戏是这样进行的,孩子们负责躲藏,Jiajia负责找,而Wind负责操纵这N个屋子的灯。在起初的时候,所有的灯都没原创 2016-05-12 14:06:41 · 469 阅读 · 0 评论 -
SPOJ QTREE4 Query on a tree IV
DescriptionYou are given a tree (an acyclic undirected connected graph) with N nodes, and nodes numbered 1,2,3...,N. Each edge has an integer value assigned to it(note that the value can be nega原创 2016-05-13 15:27:26 · 1222 阅读 · 0 评论 -
POJ 1741 Tree
DescriptionGive 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)原创 2016-05-04 22:11:06 · 266 阅读 · 0 评论 -
HYSBZ 2152 聪聪可可
Description聪聪和可可是兄弟俩,他们俩经常为了一些琐事打起来,例如家中只剩下最后一根冰棍而两人都想吃、两个人都想玩儿电脑(可是他们家只有一台电脑)……遇到这种问题,一般情况下石头剪刀布就好了,可是他们已经玩儿腻了这种低智商的游戏。他们的爸爸快被他们的争吵烦死了,所以他发明了一个新游戏:由爸爸在纸上画n个“点”,并用n-1条“边”把这n个“点”恰好连通(其实这就是一棵树)。并且原创 2016-05-04 22:13:19 · 432 阅读 · 0 评论 -
HDU 4871 Shortest-path tree
DescriptionGiven a connected, undirected graph G, a shortest-path tree rooted at vertex v is a spanning tree T of G, such that the path distance from root v to any other vertex u in T is the short原创 2016-05-07 14:17:41 · 618 阅读 · 0 评论