图论
YCQ_Lancet
骐骥一跃,不能十步,驽马十驾,功在不舍
展开
-
D - Restoration of string 图论,拓扑序
D. Restoration of stringtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputA substring of some string is called the mos原创 2017-11-14 11:11:27 · 279 阅读 · 0 评论 -
Dining POJ - 3281 思维建图+最大流
Cows 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 to check his me原创 2017-08-03 09:16:58 · 299 阅读 · 0 评论 -
ACM Computer Factory POJ - 3436
As 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 factory.Ever原创 2017-08-02 19:12:43 · 280 阅读 · 0 评论 -
Farm Tour POJ - 2135 最小费用最大流(模板)
When FJ's friends visit him on the farm, he likes to show them around. His farm comprises N (1 <= N <= 1000) fields numbered 1..N, the first of which contains his house and the Nth of which contains t原创 2017-08-02 11:06:50 · 316 阅读 · 0 评论 -
迷宫 FZU - 2256
某一天,YellowStar在人生的道路上迷失了方向,迷迷糊糊之中,它误入了一座迷宫中,幸运的是它在路口处发现了一张迷宫的地图。经过它的观察,它发现这个迷宫一共有n个房间,并且这n个房间呈现一个有根树结构,它现在所在的1号房间为根,其它每个房间都有一个上级房间,连接第i个房间和它的上级房间Pi的道路长度为Wi。在地图的背面,记载了这个迷宫中,每个房间拥有一个时空传送门,第i个房间的传送门可原创 2017-07-24 20:10:53 · 470 阅读 · 0 评论 -
浪里个浪 FZU - 2261
TonyY是一个喜欢到处浪的男人,他的梦想是带着兰兰姐姐浪遍天朝的各个角落,不过在此之前,他需要做好规划。现在他的手上有一份天朝地图,上面有n个城市,m条交通路径,每条交通路径都是单行道。他已经预先规划好了一些点作为旅游的起点和终点,他想选择其中一个起点和一个终点,并找出从起点到终点的一条路线亲身体验浪的过程。但是他时间有限,所以想选择耗时最小的,你能告诉他最小的耗时是多少吗?In原创 2017-07-24 19:36:25 · 335 阅读 · 0 评论 -
最大流dinic算法的优化模板 当前弧优化,多路增广
最大流算法优化,当前弧优化,多路增广原创 2017-08-01 21:55:17 · 556 阅读 · 0 评论 -
Control HDU - 4289 最大流拆点
You, the head of Department of Security, recently received a top-secret information that a group of terrorists is planning to transport some WMD1 from one city (the source) to another one (the desti原创 2017-08-08 08:49:33 · 316 阅读 · 0 评论 -
Godfather POJ - 3107
Last years Chicago was full of gangster fights and strange murders. The chief of the police got really tired of all these crimes, and decided to arrest the mafia leaders.Unfortunately, the structure原创 2017-06-25 20:45:18 · 285 阅读 · 0 评论 -
Those are not the droids you're looking for Gym - 100285H 二分图 最大流
题目根本粘贴不上,口述一波。题目大意:有一天警察去一个酒吧去抓机器人,酒吧的老板说他这里只有两种人,没有机器人,这两种人的特点是,第一种人会在酒吧呆至少A个小时,另一种人会在网吧最多呆B个小时。现在给你酒吧门的进出记录,让酒吧老板自圆其说,如果不能自圆其说就说明老板是个骗子,否则就输出详细的人物进入与离开的时间。首先想到二分匹配,大概做法就是建图+最大流。方法:设超级起点s,超级终点f原创 2017-08-10 21:36:36 · 302 阅读 · 0 评论 -
A Plug for UNIX POJ - 1087 最大流 思维建图
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 free flow of information and id原创 2017-08-03 21:43:10 · 351 阅读 · 0 评论 -
Strongly connected HDU - 4635 强连通
Give a simple directed graph with N nodes and M edges. Please tell me the maximum number of the edges you can add that the graph is still a simple directed graph. Also, after you add these edges, this原创 2017-08-31 14:30:08 · 418 阅读 · 1 评论 -
Network of Schools POJ - 1236 Tarjan强连通
A number of schools are connected to a computer network. Agreements have been developed among those schools: each school maintains a list of schools to which it distributes software (the “receiving sc原创 2017-08-24 08:14:01 · 279 阅读 · 0 评论 -
HDU 4612 Warm up 边双联通分量,树宽
N planets are connected by M bidirectional channels that allow instant transportation. It's always possible to travel between any two planets through these channels. If we can isolate some planet原创 2017-08-25 20:46:46 · 293 阅读 · 0 评论 -
Redundant Paths POJ - 3177 边双联通分量
In order to get from one of the F (1 <= F <= 5,000) grazing fields (which are numbered 1..F) to another field, Bessie and the rest of the herd are forced to cross near the Tree of Rotten Apples. The c原创 2017-08-25 11:25:51 · 309 阅读 · 0 评论 -
POJ 3694 Network tarjan+LCA
A 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 successive li原创 2017-08-25 10:19:53 · 278 阅读 · 0 评论 -
Dropping Balls UVA - 679
这道题如果去天真的模拟就跪了,于是就想到找什么规律。其实每一个节点是第几次到第几个节点都是有规律可以找到的。比如说从出发根节点:只能是第偶数个节点到右子树,奇数个到左子树。这样的话直接一层一层的查找最后一个节点就可以了AC代码:#includeusing namespace std;int n;int main(){ int t; while(scanf("%d原创 2017-07-28 20:29:11 · 357 阅读 · 0 评论 -
Funny Car Racing UVA - 12661 (当初就不该浪的最短路)
比赛题目,当时其实按照我的做法去写就写出来了,可是由于不该浪的时候在浪,所以就把自己的结论给推翻了,这么多人没做出来以为这道题很难,其实是简单*********最短路的dis数组记录的当前最短路,也就是当前的时间,根据当前的时间你可以去确定从这点出发到联通路的数值,这不就是一个裸的最短路啊。只需要在更新的时候判断一下权值就可以了啊。哎,辛亏是平时训练赛,区域赛一定不能这样。#include原创 2017-07-27 20:00:06 · 341 阅读 · 0 评论 -
Going Home POJ - 2195 最小费用最大流
On 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 man, you need t原创 2017-08-04 10:19:36 · 248 阅读 · 0 评论 -
Kingdoms UVA - 12507 状压||dfs搜索+最小生成树
A kingdom has n cities numbered 1 to n, and some bidirectional roads connecting cities. The capital is always city 1. After a war, all the roads of the kingdom are destroyed. The king wants to rebuild原创 2017-06-24 22:02:34 · 345 阅读 · 0 评论 -
Bear and Clique Distances CodeChef - CLIQUED (最短路)
Read problems statements in Mandarin Chinese, Russian and Vietnamese as well.Bearland consists of N cities, numbered 1 through N. Cities are connected with bidirectional roads.Cities 1 throu原创 2017-06-23 19:00:51 · 614 阅读 · 0 评论 -
Layout POJ - 3169 差分约束
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 standin原创 2017-06-08 15:15:53 · 398 阅读 · 0 评论 -
Heavy Transportation POJ - 1797
Background 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 place his cu原创 2017-06-08 15:49:15 · 183 阅读 · 0 评论 -
Frogger POJ - 2253
Freddy 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 tourists' sun原创 2017-06-08 15:37:15 · 188 阅读 · 0 评论 -
HDU 4370 0 or 1
Given a n*n matrix C ij (1<=i,j<=n),We want to find a n*n matrix Xij (1Besides,X ij meets the following conditions: 1.X 12+X 13+...X 1n=1 2.X 1n+X 2n+...X n-1n=1 3.for each i (1ki (1ij (原创 2017-06-07 17:24:00 · 334 阅读 · 0 评论 -
The Tag Game
C. The Tag Gametime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputAlice got tired of playing the tag game by the usual r原创 2017-06-06 19:24:21 · 622 阅读 · 0 评论 -
Roads and Libraries
The Ruler of HackerLand believes that every citizen of the country should have access to a library. Unfortunately, HackerLand was hit by a tornado that destroyed all of its libraries and obstructed it原创 2017-06-18 08:38:00 · 374 阅读 · 0 评论 -
hdu 1325 Is It A Tree?
A tree is a well-known data structure that is either empty (null, void, nothing) or is a set of one or more nodes connected by directed edges between nodes satisfying the following properties.Th原创 2017-06-11 20:55:20 · 189 阅读 · 0 评论 -
HDU 1272 小希的迷宫(图论+STL应用)
上次Gardon的迷宫城堡小希玩了很久(见Problem B),现在她也想设计一个迷宫让Gardon来走。但是她设计迷宫的思路不一样,首先她认为所有的通道都应该是双向连通的,就是说如果有一个通道连通了房间A和B,那么既可以通过它从房间A走到房间B,也可以通过它从房间B走到房间A,为了提高难度,小希希望任意两个房间有且仅有一条路径可以相通(除非走了回头路)。小希现在把她的设计图给你,让你帮忙判断她的原创 2017-06-11 17:41:52 · 245 阅读 · 0 评论 -
D. Okabe and City codeforces 最短路
D. Okabe and Citytime limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputOkabe likes to be able to walk through his city on原创 2017-07-02 08:44:34 · 436 阅读 · 0 评论 -
昂贵的聘礼 POJ - 1062
年轻的探险家来到了一个印第安部落里。在那里他和酋长的女儿相爱了,于是便向酋长去求亲。酋长要他用10000个金币作为聘礼才答应把女儿嫁给他。探险家拿不出这么多金币,便请求酋长降低要求。酋长说:"嗯,如果你能够替我弄到大祭司的皮袄,我可以只要8000金币。如果你能够弄来他的水晶球,那么只要5000金币就行了。"探险家就跑到大祭司那里,向他要求皮袄或水晶球,大祭司要他用金币来换,或者替他弄来其他的东西,原创 2017-06-08 16:23:48 · 275 阅读 · 0 评论 -
URAL - 1930
The world is in danger! Awful earthquakes are detected all over the world. Houses are destroyed, rivers overflow the banks, it is almost impossible to move from one city to another. Some roads are sti原创 2017-06-16 11:14:05 · 414 阅读 · 0 评论