
图论算法
文章平均质量分 78
图论相关算法
CXY_Likescoding
不失情怀,不忘初心!
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
HDU 4786 Fibonacci Tree(最小生成树变式)
Problem Description Coach Pang is interested in Fibonacci numbers while Uncle Yang wants him to do some research on Spanning Tree. So Coach Pang decides to solve the following problem: Conside原创 2017-08-20 22:34:30 · 351 阅读 · 0 评论 -
CCF 地铁修建(Dijkstra 变式)
问题描述 A市有n个交通枢纽,其中1号和n号非常重要,为了加强运输能力,A市决定在1号到n号枢纽间修建一条地铁。 地铁由很多段隧道组成,每段隧道连接两个交通枢纽。经过勘探,有m段隧道作为候选,两个交通枢纽之间最多只有一条候选的隧道,没有隧道两端连接着同一个交通枢纽。 现在有n家隧道施工的公司,每段候选的隧道只能由一个公司施工,每家公司施工需要的天数一致。而每家公司最多只能修建一条原创 2017-04-03 19:13:24 · 2276 阅读 · 3 评论 -
POJ 3259 Wormholes(SPFA 判负环)
While exploring his many farms, Farmer John has discovered a number of amazing wormholes. A wormhole is very peculiar because it is a one-way path that delivers you to its destination at a time that i原创 2017-03-25 20:50:03 · 356 阅读 · 0 评论 -
POJ 3268 Silver Cow Party(Dijkstra)
DescriptionOne cow from each of N farms (1 ≤ N ≤ 1000) conveniently numbered 1..N is going to attend the big cow party to be held at farm #X (1 ≤X ≤ N). A total of M (1 ≤ M ≤ 100,000) unidirectional...原创 2017-01-22 23:43:02 · 286 阅读 · 0 评论 -
POJ 1797 Heavy Transportation(Dijkstra变式)
DescriptionBackground Hugo Heavy is happy. After the breakdown of the Cargolifter project he can now expand business. But he needs a clever man who tells him whether there really is a way from the原创 2017-01-22 13:19:07 · 294 阅读 · 0 评论 -
POJ 2387 Til the Cows Come Home(Dijkstra)
DescriptionBessie is out in the field and wants to get back to the barn to get as much sleep as possible before Farmer John wakes her for the morning milking. Bessie needs her beauty sleep, so she w原创 2017-01-22 09:20:48 · 296 阅读 · 0 评论 -
POJ 2253 Frogger(Dijkstra变式)
DescriptionFreddy Frog is sitting on a stone in the middle of a lake. Suddenly he notices Fiona Frog who is sitting on another stone. He plans to visit her, but since the water is dirty and full of原创 2017-01-22 08:53:08 · 491 阅读 · 0 评论 -
POJ 3436 ACM Computer Factor (最大流)
DescriptionAs you know, all the computers used for ACM contests must be identical, so the participants compete on equal terms. That is why all these computers are historically produced at the same fac...原创 2018-05-09 16:34:41 · 320 阅读 · 0 评论 -
POJ 3155 Hard Life(最小割 最大密度子图)
DescriptionJohn is a Chief Executive Officer at a privately owned medium size company. The owner of the company has decided to make his son Scott a manager in the company. John fears that the owne原创 2017-09-21 20:20:23 · 579 阅读 · 0 评论 -
HDU 6214 Smallest Minimum Cut(网络流 最小割最少边数)
Problem DescriptionConsider a network G=(V,E) with source s and sink t. An s-t cut is a partition of nodes set V into two parts such that s and t belong to different parts. The cut set is the subset...原创 2017-09-18 23:55:26 · 566 阅读 · 0 评论 -
POJ 1087 A Plug for UNIX(网络流)
DescriptionYou are in charge of setting up the press room for the inaugural meeting of the United Nations Internet eXecutive (UNIX), which has an international mandate to make the free flow of infor原创 2017-04-06 20:50:11 · 303 阅读 · 0 评论 -
POJ 2195 Going Home(最小费用最大流)
DescriptionOn a grid map there are n little men and n houses. In each unit time, every little man can move one unit step, either horizontally, or vertically, to an adjacent point. For each little ma原创 2017-04-03 18:08:13 · 321 阅读 · 0 评论 -
POJ 3281 Dining(网络流)
DescriptionCows are such finicky eaters. Each cow has a preference for certain foods and drinks, and she will consume no others.Farmer John has cooked fabulous meals for his cows, but he forgot原创 2017-04-02 16:52:32 · 452 阅读 · 0 评论 -
HDU 1150 Machine Schedule(最大流)
Problem DescriptionAs we all know, machine scheduling is a very classical problem in computer science and has been studied for a very long history. Scheduling problems differ widely in the nature of...原创 2018-05-17 23:23:04 · 271 阅读 · 0 评论 -
Leetcode 685. 冗余连接 II(拓扑排序+并查集)
[题目链接]思路:\qquad根据题意,题目中的有向图为一棵树加上一条冗余边。一棵树的所有子节点入度均为1,根节点入度为0,因此可以分为以下两种情况:\qquad (1)图中存在入度为2的节点。因为根节点的入度为0,添加一条边,入度最多加1,因此入度为2的点一定是子节点,要删除的边一定是连向这个节点的边之一,根是入度为0的节点。此时考虑删掉每条连向该节点的边,对剩下的图从根节点拓扑排序,若没有环且能遍历到所有点,则枚举的边就是答案;\qquad(2)图中点的入度均为1,即从子节点向根节点连一条边。此原创 2020-09-19 13:23:16 · 209 阅读 · 0 评论 -
POJ 2186 Popular Cows(Tarjan + 强连通分量缩点)
DescriptionEvery cow's dream is to become the most popular cow in the herd. In a herd of N (1 <= N <= 10,000) cows, you are given up to M (1 <= M <= 50,000) ordered pairs of the form (A, B) that tel原创 2017-09-08 11:41:33 · 398 阅读 · 0 评论 -
POJ 1330 Nearest Common Ancestors(LCA 在线算法)
DescriptionA rooted tree is a well-known data structure in computer science and engineering. An example is shown below:In the figure, each node is labeled with an integer from {1, 2,...,16}.原创 2017-09-09 10:48:23 · 283 阅读 · 0 评论 -
POJ 1330 Nearest Common Ancestors(LCA 离线算法)
DescriptionA rooted tree is a well-known data structure in computer science and engineering. An example is shown below:In the figure, each node is labeled with an integer from {1, 2,...,16}.原创 2017-09-09 23:22:33 · 323 阅读 · 0 评论 -
Codeforces Round #479(DFS)
E. Cyclic ComponentsYou are given an undirected graph consisting of n vertices and m edges. Your task is to find the number of connected components which are cycles.Here are some definitions of gr...原创 2018-05-31 11:59:17 · 566 阅读 · 0 评论 -
POJ 3660 Cow Contest
N (1 ≤ N ≤ 100) cows, conveniently numbered 1..N, are participating in a programming contest. As we all know, some cows code better than others. Each cow has a certain constant skill rating that is un原创 2017-03-26 00:12:08 · 375 阅读 · 0 评论