
图论
文章平均质量分 81
小小小小葱
这个作者很懒,什么都没留下…
展开
-
网络流 最大流 Edmonds-Karp算法
Edmonds-Karp算法,复杂度O(VE^2)。思想就是找增广路,不断增加流量。在残量(每条边上流量和容量的差)图上找一条每个边权值都为正的路(可以通过BFS,比DFS效率高),这些边权值里的最小值就是这条路可以增加的流量,然后在这条路径上更新流量。再重复找这样的路更新流量,直到找不到这样的路了就说明流量不能再增加了,当前的流就已经是最大流。 同时最大流也是最小割(权值和最小的割集)。设原创 2014-01-21 17:20:57 · 1701 阅读 · 0 评论 -
uva1364 - Knights of the Round Table 点-双联通分量
Being a knight is a very attractive career: searching for the Holy Grail, saving damsels in distress, and drinking with the other knights are fun things to do. Therefore, it is not very surprising tha原创 2014-09-17 20:08:00 · 409 阅读 · 0 评论 -
Dinic+当前弧优化
Dinic算法是不停用BFS构造层次图,然后原创 2014-09-29 20:51:13 · 7016 阅读 · 1 评论 -
uva1324 - Bring Them There 网络流
By the year 3141, the human civilization has spread all over the galaxy. The special hypertunnels are usedto travel from one star system to another. To use the hypertunnel, you fly to a special locati原创 2014-10-01 22:15:07 · 741 阅读 · 0 评论 -
uva1306 - The K-League 网络流
Supporters for the professional soccer clubs participating in the K-League, formerly the Korea Professional Soccer League, hold orderly and organized cheering, as did the Red Devils, the official supp原创 2014-10-02 19:53:24 · 658 阅读 · 0 评论 -
uva11613 - Acme Corporation 费用流
Wile E. Coyote is back. He is back inthe business. The business of capturing the road runner. Being the most loyalcustomer to the Acme Corporation, they are hoping to do some great businesswith him. A原创 2014-10-02 20:16:42 · 601 阅读 · 0 评论 -
uva707 - Robbery 记忆化搜索
Robbery Inspector Robstop is very angry. Last night, a bank has been robbed and the robber has not been caught. And this happened already for the third time this year, even though he did原创 2015-02-17 19:03:12 · 526 阅读 · 0 评论 -
uva10441 - Catenyms 欧拉通路
Problem C: CatenymsA catenym is a pair of words separated by a period such that the last letter of the first word is the same as the first letter of the second. For example, the following are cateny原创 2015-02-17 18:50:10 · 455 阅读 · 0 评论 -
uva11367 - Full Tank? 最短路 DP
F: Full Tank? After going through the receipts from your car trip through Europe this summer, you realised that the gas prices varied between the cities you visited. Maybe you could have sav原创 2015-02-22 12:05:36 · 518 阅读 · 0 评论 -
poj2449 Remmarguts' Date 第K短路 A*
Remmarguts' DateTime Limit: 4000MS Memory Limit: 65536KTotal Submissions: 22226 Accepted: 6023Description"Good man never makes girls wait or breaks an appointment!"原创 2015-02-22 11:28:15 · 296 阅读 · 0 评论 -
uva10806 - Dijkstra, Dijkstra. 最小费用流 求两条路权值之和最小
最小费用流是每次在残量图中求出起点到终点的最短路,然后再找出最短路上权值最小的一个边作为增广流量进行增广,更新流量,加上费用(最短路*增广流量)。找最短路用的不带链接表的spfa算法。因为每次增广后都是新流量下的最小费用流,所以最后就是最大流的最小费用。 如果是无向图、有平行边和反向边就比较麻烦了。。在有向图,没有平行边和反向边的情况下,设cap[v][u]=0,cost[v][u]=-co原创 2014-01-21 20:35:37 · 722 阅读 · 0 评论 -
uva11865 - Stream My Contest 最小树形图+二分
GStream My ContestInput: Standard InputOutput: Standard Output During 2009 and 2010 ICPC world finals, the contest was webcasted via world wide web. Seeing this, some c原创 2015-02-26 11:56:31 · 395 阅读 · 0 评论 -
uva10600 - ACM Contest and Blackout 次小生成树
Problem AACM CONTEST AND BLACKOUT In order to prepare the “The First National ACM School Contest”(in 20??) the major of the city decided to provide all the schools with a reliable source of原创 2015-02-23 19:38:51 · 492 阅读 · 0 评论 -
最小树形图 朱刘算法
最小树形图,就是给有向带权图中指定一个特殊的点root,求一棵以root为根的有向生成树T,并且T中所有边的总权值最小。 LRJ的代码。。先原创 2014-09-27 10:41:39 · 600 阅读 · 0 评论 -
uva1494 - Qin Shi Huang's National Road System 次小生成树
During the Warring States Period of ancient China(476 BC to 221 BC), there were seven kingdoms in China -- they were Qi, Chu, Yan, Han, Zhao, Wei and Qin. Ying Zheng was the king of the kingdom Qin. T原创 2014-09-26 19:52:53 · 460 阅读 · 0 评论 -
Codeforces Round #286 (Div. 1) B. Mr. Kitayuta's Technology 连通分量 拓扑排序
B. Mr. Kitayuta's Technologytime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputShuseki Kingdom is the world's leading na原创 2015-01-24 18:28:58 · 612 阅读 · 0 评论 -
sdut2414 An interesting game 费用流
An interesting gameTime Limit: 2000ms Memory limit: 65536K 有疑问?点这里^_^题目描述Xiao Ming recently designs a little game, in front of player there are N small hillsides put in order, now Xia原创 2015-04-13 20:21:00 · 655 阅读 · 0 评论 -
uva1416 - Warfare And Logistics 最短路树优化
The army of United Nations launched a new wave of air strikes on terroristforces. The objective of the mission is to reduce enemy's logistical mobility. Each airstrike will destroy a path and therefor原创 2014-09-25 17:53:16 · 914 阅读 · 0 评论 -
uva11354 - Bond 最小瓶颈路+LCA
Once again, James Bond is on his way tosaving the world. Bond's latest mission requires him to travel between severalpairs of cities in a certain country. The country has N cities(numbered by 1, 2原创 2014-09-26 20:08:20 · 637 阅读 · 0 评论 -
uva11374 - Airport Express 最短路
In a small city called Iokh, a train service, Airport-Express, takes residents to the airport more quickly than other transports. There are two types of trains in Airport-Express, theEconomy-Xpress原创 2014-09-19 18:28:55 · 465 阅读 · 0 评论 -
uva563 - Crimewave 拆点+链接表的最大流
Crimewave Nieuw Knollendam is a very modern town. This becomes clear already when looking at the layout of its map, which is just a rectangular grid of streets and avenues. Being an impo原创 2014-01-22 18:25:35 · 502 阅读 · 0 评论 -
uva753 - A Plug for UNIX 网络流 插头匹配
A Plug for UNIX You 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 fre原创 2014-01-22 15:13:18 · 633 阅读 · 0 评论 -
uva10594 - Data Flow 无向图的最小费用
Problem FData FlowTime Limit5 Seconds In the latest Lab of IIUC, it requires to send huge amount of data from the local server to the terminal server. The lab setup原创 2014-01-23 17:35:11 · 553 阅读 · 0 评论 -
Bellman_Ford和Spfa两种方法判断负环
Bellman_Ford是通过N-1次循环求出每个点到原点的最短路的,每次循环遍历所有的边,如果能更新就更新。前面说过为什么N-1次就行(若一个点到起点的最短路需要经过N个点,包括他自己,那么第N次循环就能确定他的最短路)。 最短路一定是不含环的,如果存在负环就根本不存在最短路了。所以这个方法可以用来判断是否有负环,如果循环了N-1次后还能进行松弛操作,说明有负环。Bellman_Ford的原创 2014-01-17 17:09:46 · 1625 阅读 · 1 评论 -
Dijkstra 求最短路 最大流
原来Dijkstra算法不光只能求最短路问题,还能求最大流问题~~~求最短路 最大流" title="Dijkstra 求最短路 最大流">最短路问题时,Dijkstra算法的基本思想: 邻接矩阵w[x][y]保存x和y间的距离(别的设为INF,表示不连通,设为-1也行,后来更新加一个if(w[x][y]>=0)),数组d保存通过已经确定的点从起点到每个点的最短路。初始化d[0]=0,原创 2013-05-28 11:16:21 · 1755 阅读 · 0 评论 -
uva658 - It's not a Bug, it's a Feature! 状态压缩+隐式图搜索+优先队列的dijkstra
It's not a Bug, it's a Feature! It is a curious fact that consumers buying a new software product generally donot expect the software to be bug-free. Can you imagine buying a car whose原创 2014-01-16 13:37:34 · 682 阅读 · 0 评论 -
差分约束系统
如果一个系统由n个变量和m个约束条件组成,其中每个约束条件形如xj-xi求解差分约束系统,可以转化成图论的单源最短路径(或最长路径)问题。观察xj-xi引理:设x=(x1,x2,…,xn)是差分约束系统Ax≤b的一个解,d为任意常数。则x+d=(x1+d,x2+d,…,xn+d)也是该系统Ax≤b的一个解。bellman-ford算法伪代码:for each v V do d原创 2014-01-20 09:54:09 · 480 阅读 · 0 评论 -
uva10269 - Adventure of Super Mario floyd+dp+spfa
Problem AAdventure of Super MarioInput: Standard InputOutput: Standard OutputAfter rescuing the beautiful princess, Super Mario needs to find a way home -- with the princess of course :-原创 2014-01-24 15:05:01 · 708 阅读 · 0 评论 -
有向图强连通分量Tarjan
这几天填鸭赛让人很无语啊。。搞一些听都没听过是什么算法的题。。 所谓强连通,就是一个图中任意两点都是连通的,比如两个点a,b,既要有a到b的路径,又要有b到a的路径。Tarjan算法是用来算强连通分量的。在网上看到有BFS和DFS的,因为DFS代码短,所以暂时只先解了DFS的。。 Tarjan算法有两个关键的数组,一个是DFN,记录结点的搜索时间编号,也就是第几个搜索到这个点的。还有一原创 2013-08-16 22:25:13 · 626 阅读 · 0 评论 -
匈牙利算法 二分图
这几个图和定义转自https://www.byvoid.com/blog/hungary/ 未盖点:设Vi是图G的一个顶点,如果Vi 不与任意一条属于匹配M的边相关联,就称Vi 是一个未盖点。交错路:设P是图G的一条路,如果P的任意两条相邻的边一定是一条属于M而另一条不属于M,就称P是一条交错路。可增广路:两个端点都是未盖点的交错路叫做可增广路。 匈牙原创 2013-08-17 19:36:14 · 632 阅读 · 0 评论 -
poj3041 Asteroids 最小点覆盖 二分图
AsteroidsTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 13927 Accepted: 7566DescriptionBessie wants to navigate her spaceship through a dangerous aster原创 2014-04-22 21:13:45 · 573 阅读 · 0 评论 -
Codeforces Round #257 (Div. 2) D. Jzzhu and Cities
D. Jzzhu and Citiestime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputJzzhu is the president of country A. There are n原创 2014-07-28 20:07:26 · 465 阅读 · 0 评论 -
uva11324 - The Largest Clique 有向图强连通分量+缩点+DP
Given a directed graph G, consider the following transformation. First, create a new graphT(G) to have the same vertex set asG. Create a directed edge betweentwo vertices u and v inT(G) if and onl原创 2014-09-18 17:40:58 · 488 阅读 · 0 评论 -
2-SAT
有N个布尔变量xi,原创 2014-09-19 14:10:45 · 534 阅读 · 0 评论 -
uva1391 - Astronauts 2-SAT
The Bandulu Space Agency (BSA) has plans for the following three space missions:Mission A: Landing on Ganymede, the largest moon of Jupiter.Mission B: Landing on Callisto, the second largest moo原创 2014-09-19 14:29:45 · 425 阅读 · 0 评论 -
hdu5294 Tricks Device 最短路+最小割 多校联合第一场
Tricks DeviceTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 66 Accepted Submission(s): 14Problem DescriptionInnocent Wu follows原创 2015-07-21 18:15:45 · 1475 阅读 · 0 评论