
ACM_树图
DATELOST
I'm curious.
展开
-
HDU-1879 kruskal算法
Problem Description:省政府“畅通工程”的目标是使全省任何两个村庄间都可以实现公路交通(但不一定有直接的公路相连,只要能间接通过公路可达即可)。现得到城镇道路统计表,表中列出了任意两城镇间修建道路的费用,以及该道路是否已经修通的状态。现请你编写程序,计算出全省畅通需要的最低成本。Input测试输入包含若干测试用例。每个测试用例的第1行给出村庄数目N ( 1< N &l...原创 2019-01-24 22:34:20 · 145 阅读 · 0 评论 -
HDU-4496 并查集 逆向加边
Problem DescriptionLuxer is a really bad guy. He destroys everything he met.One day Luxer went to D-city. D-city has N D-points and M D-lines. Each D-line connects exactly two D-points. Luxer will d...原创 2019-03-09 20:58:48 · 223 阅读 · 0 评论 -
HDU-3018 并查集 欧拉回路
Problem DescriptionAnt Country consist of N towns.There are M roads connecting the towns.Ant Tony,together with his friends,wants to go through every part of the country.They intend to visit every ...原创 2019-03-08 18:01:14 · 176 阅读 · 0 评论 -
HDU-2444 判断二分图,最大匹配
Problem DescriptionThere are a group of students. Some of them may know each other, while others don’t. For example, A and B know each other, B and C know each other. But this may not imply that A an...原创 2019-03-16 23:37:22 · 141 阅读 · 0 评论 -
POJ-1679 kruskal算法 最小生成树唯一?
DescriptionGiven a connected undirected graph, tell if its minimum spanning tree is unique.Definition 1 (Spanning Tree): Consider a connected, undirected graph G = (V, E). A spanning tree of G is a ...原创 2019-03-27 22:59:55 · 568 阅读 · 0 评论 -
POJ-1556 判断相交+dijkstra
DescriptionYou are to find the length of the shortest path through a chamber containing obstructing walls. The chamber will always have sides at x = 0, x = 10, y = 0, and y = 10. The initial and fina...原创 2019-04-07 20:47:34 · 126 阅读 · 0 评论 -
HDU-1251 Trie
Problem DescriptionIgnatius最近遇到一个难题,老师交给他很多单词(只有小写字母组成,不会有重复的单词出现),现在老师要他统计出以某个字符串为前缀的单词数量(单词本身也是自己的前缀).Input输入数据的第一部分是一张单词表,每行一个单词,单词的长度不超过10,它们代表的是老师交给Ignatius统计的单词,一个空行代表单词表的结束.第二部分是一连串的提问,每行一个提...原创 2019-07-18 20:10:05 · 98 阅读 · 0 评论 -
HDU-2767 tarjan缩点
InputOn the first line one positive number: the number of testcases, at most 100. After that per testcase:One line containing two integers n (1 ≤ n ≤ 20000) and m (0 ≤ m ≤ 50000): the number of sta...原创 2019-07-28 23:08:49 · 164 阅读 · 0 评论 -
HDU-1827 tarjan缩点
Problem Description听说lcy帮大家预定了新马泰7日游,Wiskey真是高兴的夜不能寐啊,他想着得快点把这消息告诉大家,虽然他手上有所有人的联系方式,但是一个一个联系过去实在太耗时间和电话费了。他知道其他人也有一些别人的联系方式,这样他可以通知其他人,再让其他人帮忙通知一下别人。你能帮Wiskey计算出至少要通知多少人,至少得花多少电话费就能让所有人都被通知到吗?Input...原创 2019-07-29 09:41:06 · 126 阅读 · 0 评论 -
HDU-3966 树链剖分 树状数组 点权
Problem DescriptionOur protagonist is the handsome human prince Aragorn comes from The Lord of the Rings. One day Aragorn finds a lot of enemies who want to invade his kingdom. As Aragorn knows, the ...原创 2019-07-21 21:59:51 · 185 阅读 · 0 评论 -
POJ-2763 树链剖分 线段树 边权
题目把边权看作点权不知道为啥N=1e5+5会wa,数组要开大点#include<iostream>#include<string.h>#include<stdio.h>using namespace std;const int N=2e5+5;int fa[N],son[N],dep[N],top[N],siz[N],pos[N],fp[N];...原创 2019-07-22 10:59:30 · 159 阅读 · 0 评论 -
P3178 树链剖分 线段树 子树加
题目输入样例#1:5 51 2 3 4 51 21 42 32 53 31 2 13 52 1 23 3输出样例#1:6913说明对于 100% 的数据, N,M<=100000 ,且所有输入数据的绝对值都不会超过 10^6因为子树的dfs序连续,所以直接区间加pos[u]+siz[u]-1,便可实现子树加;#include<bits/stdc+...原创 2019-07-22 14:08:47 · 167 阅读 · 0 评论 -
cf 600E/570D DSU on the tree 树上启发式合并
学习学习600E板子#include<bits/stdc++.h>using namespace std;typedef long long ll;const int N=2e5+5;int fa[N],son[N],siz[N];struct Edge{ int to,next; Edge(){} Edge(int to,int next):to(to),nex...原创 2019-07-22 21:56:55 · 132 阅读 · 0 评论 -
HDU-2586 倍增lca
Problem DescriptionThere are n houses in the village and some bidirectional roads connecting them. Every day peole always like to ask like this “How far is it if I want to go from house A to house B”...原创 2019-07-26 22:41:55 · 122 阅读 · 0 评论 -
POJ-3694 tarjan 割边 并查集缩点
DescriptionA network administrator manages a large network. The network consists of N computers and M links between pairs of computers. Any pair of computers are connected directly or indirectly by s...原创 2019-07-27 23:58:26 · 198 阅读 · 0 评论 -
HDU-1179 匈牙利算法
InputThere are several cases. For each case, there is two integers N and M in the first line,which mean there is N wizards and M wands(0 < N <= M <= 100).Then M lines contain the choices of...原创 2019-03-01 21:44:22 · 190 阅读 · 0 评论 -
HDU-1534 SPFA 差分约束
Problem DescriptionA project can be divided into several parts. Each part should be completed continuously. This means if a part should take 3 days, we should use a continuous 3 days do complete it. ...原创 2019-03-01 00:03:24 · 165 阅读 · 0 评论 -
HDU-2066 Floyd
Problem Description虽然草儿是个路痴(就是在杭电待了一年多,居然还会在校园里迷路的人,汗~),但是草儿仍然很喜欢旅行,因为在旅途中 会遇见很多人(白马王子),很多事,还能丰富自己的阅历,还可以看美丽的风景……草儿想去很多地方,她想要去东京铁塔看夜景,去威尼斯看电影,去阳明山上看海芋,去纽约纯粹看雪景,去巴黎喝咖啡写信,去北京探望孟姜女……眼看寒假就快到了,这么一大段时间,可不能...原创 2019-02-13 13:32:10 · 172 阅读 · 0 评论 -
HDU-1811 并查集
Problem Description:呃…变形课上Harry碰到了一点小麻烦,因为他并不像Hermione那样能够记住所有的咒语而随意的将一个棒球变成刺猬什么的,但是他发现了变形咒语的一个统一规律:如果咒语是以a开头b结尾的一个单词,那么它的作用就恰好是使A物体变成B物体.Harry已经将他所会的所有咒语都列成了一个表,他想让你帮忙计算一下他是否能完成老师的作业,将一个B(ball)变成一个...原创 2019-02-07 21:41:08 · 185 阅读 · 0 评论 -
HDU-1272 并查集判断无向图的环
Problem Description:上次Gardon的迷宫城堡小希玩了很久(见Problem B),现在她也想设计一个迷宫让Gardon来走。但是她设计迷宫的思路不一样,首先她认为所有的通道都应该是双向连通的,就是说如果有一个通道连通了房间A和B,那么既可以通过它从房间A走到房间B,也可以通过它从房间B走到房间A,为了提高难度,小希希望任意两个房间有且仅有一条路径可以相通(除非走了回头路)。...原创 2019-02-08 14:33:37 · 220 阅读 · 0 评论 -
HDU-1863 kruskal算法
Problem Description:省政府“畅通工程”的目标是使全省任何两个村庄间都可以实现公路交通(但不一定有直接的公路相连,只要能间接通过公路可达即可)。经过调查评估,得到的统计表中列出了有可能建设公路的若干条道路的成本。现请你编写程序,计算出全省畅通需要的最低成本。Input测试输入包含若干测试用例。每个测试用例的第1行给出评估的道路条数 N、村庄数目M ( < 100 );...原创 2019-02-08 18:40:14 · 181 阅读 · 0 评论 -
HDU-1198 并查集
Problem Description:Benny has a spacious farm land to irrigate. The farm land is a rectangle, and is divided into a lot of samll squares. Water pipes are placed in these squares. Different square has...原创 2019-02-09 11:13:33 · 273 阅读 · 0 评论 -
HDU-1317 Bellman_ford 判环
Problem DescriptionIt has recently been discovered how to run open-source software on the Y-Crate gaming device. A number of enterprising designers have developed Advent-style games for deployment on...原创 2019-02-16 10:51:55 · 227 阅读 · 0 评论 -
HDU-3367 最大生成树
Problem DescriptionIn graph theory, a pseudoforest is an undirected graph in which every connected component has at most one cycle. The maximal pseudoforests of G are the pseudoforest subgraphs of G ...原创 2019-02-09 18:53:46 · 205 阅读 · 0 评论 -
HDU-1535 Dijkstra 链式向前星
Problem DescriptionIn the age of television, not many people attend theater performances. Antique Comedians of Malidinesia are aware of this fact. They want to propagate theater and, most of all, Ant...原创 2019-02-16 14:00:29 · 281 阅读 · 0 评论 -
HDU-4857 拓扑排序 反向建图
Problem Description糟糕的事情发生啦,现在大家都忙着逃命。但是逃命的通道很窄,大家只能排成一行。现在有n个人,从1标号到n。同时有一些奇怪的约束条件,每个都形如:a必须在b之前。同时,社会是不平等的,这些人有的穷有的富。1号最富,2号第二富,以此类推。有钱人就贿赂负责人,所以他们有一些好处。负责人现在可以安排大家排队的顺序,由于收了好处,所以他要让1号尽量靠前,如果此时还...原创 2019-02-22 09:52:04 · 161 阅读 · 0 评论 -
HDU-1285 拓扑排序 字典序最小
Problem Description有N个比赛队(1<=N<=500),编号依次为1,2,3,。。。。,N进行比赛,比赛结束后,裁判委员会要将所有参赛队伍从前往后依次排名,但现在裁判委员会不能直接获得每个队的比赛成绩,只知道每场比赛的结果,即P1赢P2,用P1,P2表示,排名时P1在P2之前。现在请你编程序确定排名。Input输入有若干组,每组中的第一行为二个数N(1<=...原创 2019-02-22 10:08:26 · 818 阅读 · 0 评论 -
HDU-1269 Tarjan
Problem Description为了训练小希的方向感,Gardon建立了一座大城堡,里面有N个房间(N<=10000)和M条通道(M<=100000),每个通道都是单向的,就是说若称某通道连通了A房间和B房间,只说明可以通过这个通道由A房间到达B房间,但并不说明通过它可以由B房间到达A房间。Gardon需要请你写个程序确认一下是否任意两个房间都是相互连通的,即:对于任意的i和j...原创 2019-02-10 22:58:32 · 103 阅读 · 0 评论 -
HDU-2647 拓扑排序
Problem DescriptionDandelion’s uncle is a boss of a factory. As the spring festival is coming , he wants to distribute rewards to his workers. Now he has a trouble about how to distribute the rewards...原创 2019-02-22 19:29:34 · 210 阅读 · 0 评论 -
HDU-3592 SPFA 差分约束
Problem DescriptionNowadays, many people want to go to Shanghai to visit the World Exhibition. So there are always a lot of people who are standing along a straight line waiting for entering. Assume ...原创 2019-02-27 22:56:07 · 111 阅读 · 0 评论 -
HDU-3790 Dijkstra
Problem Description给你n个点,m条无向边,每条边都有长度d和花费p,给你起点s终点t,要求输出起点到终点的最短距离及其花费,如果最短距离有多条路线,则输出花费最少的。Input输入n,m,点的编号是1~n,然后是m行,每行4个数 a,b,d,p,表示a和b之间有一条边,且其长度为d,花费为p。最后一行是两个数 s,t;起点s,终点。n和m为0时输入结束。(1&lt;n&...原创 2019-02-13 10:02:08 · 141 阅读 · 0 评论 -
HDU-1595 枚举+Dijkstra
Problem DescriptionMarica is very angry with Mirko because he found a new girlfriend and she seeks revenge.Since she doesn’t live in the same city, she started preparing for the long journey.We know ...原创 2019-02-23 23:03:30 · 250 阅读 · 0 评论 -
ACwing-164. 可达性统计 拓扑排序
给定一张N个点M条边的有向无环图,分别统计从每个点出发能够到达的点的数量。输入格式第一行两个整数N,M,接下来M行每行两个整数x,y,表示从x到y的一条有向边。输出格式输出共N行,表示每个点能够到达的点的数量。数据范围1≤N,M≤30000输入样例:10 103 82 32 55 95 92 33 94 82 104 9输出样例:1633211...原创 2019-08-13 10:09:00 · 299 阅读 · 0 评论