图论
文章平均质量分 78
云淡风轻jzl
一路脚踏实地,不忘仰望星空。
展开
-
CodeForces-1196F-K-th Path-贪心建图
http://codeforces.com/problemset/problem/1196/F题目描述:You are given a connected undirected weighted graph consisting of n vertices and m edges.You need to print the k-th smallest shortest path in this graph (paths from the vertex to itself are not counted原创 2021-04-28 18:35:45 · 237 阅读 · 0 评论 -
洛谷-P1113 杂务-拓扑+状态转移
题目描述:John的农场在给奶牛挤奶前有很多杂务要完成,每一项杂务都需要一定的时间来完成它。比如:他们要将奶牛集合起来,将他们赶进牛棚,为奶牛清洗乳房以及一些其它工作。尽早将所有杂务完成是必要的,因为这样才有更多时间挤出更多的牛奶。当然,有些杂务必须在另一些杂务完成的情况下才能进行。比如:只有将奶牛赶进牛棚才能开始为它清洗乳房,还有在未给奶牛清洗乳房之前不能挤奶。我们把这些工作称为完成本项工作的准备工作。至少有一项杂务不要求有准备工作,这个可以最早着手完成的工作,标记为杂务1。John有需要完成的nnn个原创 2021-03-25 20:59:00 · 188 阅读 · 1 评论 -
东北四省赛E-Minimum Spanning Tree-贡献求和
题目描述:In the mathematical discipline of graph theory, the line graph of a simple undirected weighted graph G is another simple undirected weighted graph L(G) that represents the adjacency between every two edges in G.Precisely speaking, for an undirected原创 2021-01-29 16:51:14 · 317 阅读 · 0 评论 -
蓝桥杯2017年第八届-分考场
题目描述:n个人参加某项特殊考试。为了公平,要求任何两个认识的人不能分在同一个考场。求是少需要分几个考场才能满足条件。输入描述:第一行,一个整数n(1<n<100),表示参加考试的人数。第二行,一个整数m,表示接下来有m行数据以下m行每行的格式为:两个整数a,b,用空格分开 (1<=a,b<=n) 表示第a个人与第b个人认识。输出描述:一行一个整数,表示最...原创 2019-05-10 11:04:50 · 373 阅读 · 0 评论 -
POJ 3020-Antenna Placement-二分图之最小路径覆盖
DescriptionThe Global Aerial Research Centre has been allotted the task of building the fifth generation of mobile phone nets in Sweden. The most striking reason why they got the job, is their discov...原创 2019-11-08 22:12:50 · 273 阅读 · 0 评论 -
POJ 3041-Asteroids-二分图最大匹配
DescriptionBessie wants to navigate her spaceship through a dangerous asteroid field in the shape of an N x N grid (1 <= N <= 500). The grid contains K asteroids (1 <= K <= 10,000), which...原创 2019-11-08 22:00:26 · 186 阅读 · 0 评论 -
二分图最大匹配模板
二分图最大匹配模板题目传送门题目描述:RPG girls今天和大家一起去游乐场玩,终于可以坐上梦寐以求的过山车了。可是,过山车的每一排只有两个座位,而且还有条不成文的规矩,就是每个女生必须找个个男生做partner和她同坐。但是,每个女孩都有各自的想法,举个例子把,Rabbit只愿意和XHD或PQK做partner,Grass只愿意和linle或LL做partner,PrincessSnow...原创 2019-11-06 09:23:08 · 182 阅读 · 0 评论 -
POJ 3169-Layout-并查集判树+搜索
An undirected graph is called a caterpillar if it is connected, has no cycles, and there is a path in the graph where every node is either on this path or a neighbor of a node on the path. This path i...原创 2019-08-01 11:33:55 · 111 阅读 · 0 评论 -
POJ 1062-昂贵的聘礼-最短路-Dijkstra+优先队列+等级限制
题目描述:年轻的探险家来到了一个印第安部落里。在那里他和酋长的女儿相爱了,于是便向酋长去求亲。酋长要他用10000个金币作为聘礼才答应把女儿嫁给他。探险家拿不出这么多金币,便请求酋长降低要求。酋长说:"嗯,如果你能够替我弄到大祭司的皮袄,我可以只要8000金币。如果你能够弄来他的水晶球,那么只要5000金币就行了。“探险家就跑到大祭司那里,向他要求皮袄或水晶球,大祭司要他用金币来换,或者替他弄来...原创 2019-08-01 17:25:39 · 155 阅读 · 0 评论 -
HDU 5137-最短路+枚举-How Many Maos Does the Guanxi Worth
“Guanxi” is a very important word in Chinese. It kind of means “relationship” or “contact”. Guanxi can be based on friendship, but also can be built on money. So Chinese often say “I don’t have one ma...原创 2019-08-01 19:21:20 · 189 阅读 · 0 评论 -
POJ 1751-Highways-最小生成树
The island nation of Flatopia is perfectly flat. Unfortunately, Flatopia has a very poor system of public highways. The Flatopian government is aware of this problem and has already constructed a numb...原创 2019-08-01 19:35:44 · 127 阅读 · 0 评论 -
HDU 2647-Reward-拓扑排序+分层计数
Dandelion’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.The workers will c...原创 2019-08-01 19:51:02 · 188 阅读 · 0 评论 -
CF 1189D1和1189D2-树的边权-思维+搜索
第一问:D1. Add on a Tree(传送门)Note that this is the first problem of the two similar problems. You can hack this problem only if you solve both problems.You are given a tree with n nodes. In the beginni...原创 2019-08-02 11:59:28 · 374 阅读 · 0 评论 -
POJ 3169-Layout-差分约束+最短路
Like everyone else, cows like to stand close to their friends when queuing for feed. FJ has N (2 <= N <= 1,000) cows numbered 1…N standing along a straight line waiting for feed. The cows are st...原创 2019-08-01 11:22:58 · 132 阅读 · 0 评论 -
POJ 1860-Currency Exchange-spfa最短路
Several currency exchange points are working in our city. Let us suppose that each point specializes in two particular currencies and performs exchange operations only with these currencies. There can...原创 2019-08-01 11:08:07 · 172 阅读 · 0 评论 -
POJ 1502-MPI Maelstrom-Floyd最短路算法
BIT has recently taken delivery of their new supercomputer, a 32 processor Apollo Odyssey distributed shared memory machine with a hierarchical communication subsystem. Valentine McKee’s research advi...原创 2019-07-29 11:05:57 · 170 阅读 · 0 评论 -
POJ 3037-Skiing-最短路-Dijkstra+优先队列优化
Bessie and the rest of Farmer John’s cows are taking a trip this winter to go skiing. One day Bessie finds herself at the top left corner of an R (1 <= R <= 100) by C (1 <= C <= 100) grid ...原创 2019-07-29 11:21:36 · 179 阅读 · 0 评论 -
HDU 2112-HDU Today-最短路-map+Dijkstra+优先队列
题目描述:经过锦囊相助,海东集团终于度过了危机,从此,HDU的发展就一直顺风顺水,到了2050年,集团已经相当规模了,据说进入了钱江肉丝经济开发区500强。这时候,XHD夫妇也退居了二线,并在风景秀美的诸暨市浬浦镇陶姚村买了个房子,开始安度晚年了。这样住了一段时间,徐总对当地的交通还是不太了解。有时很郁闷,想去一个地方又不知道应该乘什么公交车,在什么地方转车,在什么地方下车(其实徐总自己有车,...原创 2019-07-29 15:51:56 · 109 阅读 · 0 评论 -
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...原创 2019-07-29 16:17:59 · 168 阅读 · 0 评论 -
POJ 1094-Sorting It All Out-多次拓扑排序
An ascending sorted sequence of distinct values is one in which some form of a less-than operator is used to order the elements from smallest to largest. For example, the sorted sequence A, B, C, D im...原创 2019-07-29 16:39:21 · 158 阅读 · 0 评论 -
蓝桥杯2017年第八届-发现环
题目描述:小明的实验室有N台电脑,编号1~N。原本这N台电脑之间有N-1条数据链接相连,恰好构成一个树形网络。在树形网络上,任意两台电脑之间有唯一的路径相连。不过在最近一次维护网络时,管理员误操作使得某两台电脑之间增加了一条数据链接,于是网络中出现了环路。环路上的电脑由于两两之间不再是只有一条路径,使得这些电脑上的数据传输出现了BUG。为了恢复正常传输。小明需要找到所有在环路上的电脑,你能帮...原创 2019-05-10 09:55:32 · 247 阅读 · 4 评论 -
HDU 1285-确定比赛名次-拓扑排序+优先队列
题目描述:有N个比赛队(1<=N<=500),编号依次为1,2,3,。。。。,N进行比赛,比赛结束后,裁判委员会要将所有参赛队伍从前往后依次排名,但现在裁判委员会不能直接获得每个队的比赛成绩,只知道每场比赛的结果,即P1赢P2,用P1,P2表示,排名时P1在P2之前。现在请你编程序确定排名。输入描述:输入有若干组,每组中的第一行为二个数N(1<=N<=500),M;其...原创 2019-07-29 16:50:22 · 182 阅读 · 0 评论 -
POJ 2631-Roads in the North-树的直径
Building and maintaining roads among communities in the far North is an expensive business. With this in mind, the roads are build such that there is only one route from a village to a village that do...原创 2019-08-03 18:56:43 · 157 阅读 · 0 评论 -
HDU 1863-畅通工程-最小生成树
题目描述:省政府“畅通工程”的目标是使全省任何两个村庄间都可以实现公路交通(但不一定有直接的公路相连,只要能间接通过公路可达即可)。经过调查评估,得到的统计表中列出了有可能建设公路的若干条道路的成本。现请你编写程序,计算出全省畅通需要的最低成本。输入描述:测试输入包含若干测试用例。每个测试用例的第1行给出评估的道路条数 N、村庄数目M ( < 100 );随后的 N行对应村庄间道路的成...原创 2019-07-29 17:10:04 · 151 阅读 · 0 评论 -
HDU 3499-Flight-最短路+反向建图
Recently, Shua Shua had a big quarrel with his GF. He is so upset that he decides to take a trip to some other city to avoid meeting her. He will travel only by air and he can go to any city if there ...原创 2019-08-02 21:37:20 · 207 阅读 · 0 评论 -
POJ 3255-Roadblocks-次短路-两次dij+枚举边
Bessie has moved to a small farm and sometimes enjoys returning to visit one of her best friends. She does not want to get to her old home too quickly, because she likes the scenery along the way. She...原创 2019-08-02 22:05:17 · 171 阅读 · 0 评论 -
POJ 3268-Silver Cow Party-单源最短路+反向记录边
One 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 (one-way roa...原创 2019-08-01 10:54:43 · 174 阅读 · 0 评论 -
POJ 2387-Til the Cows Come Home-Dijkstra+优先队列优化-两种存图方式
Bessie 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 wants to get b...原创 2019-07-29 10:54:53 · 145 阅读 · 0 评论