![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
图论算法
sdau20163940
努力学习,天天向上!
展开
-
#1182 : 欧拉路·三
#1182 : 欧拉路·三时间限制:10000ms单点时限:1000ms内存限制:256MB描述小Hi和小Ho破解了一道又一道难题,终于来到了最后一关。只要打开眼前的宝箱就可以通关这个游戏了。宝箱被一种奇怪的机关锁住:这个机关是一个圆环,一共有2^N个区域,每个区域都可以改变颜色,在黑白两种颜色之间切换。小Ho控制主角在周围探索了一下,果然又发现了一个纸片:机关黑色的部分表示为1,白色的部分表示为...原创 2018-03-24 21:16:30 · 178 阅读 · 0 评论 -
Power Network (最大流)
A power network consists of nodes (power stations, consumers and dispatchers) connected by power transport lines. A node u may be supplied with an amount s(u) >= 0 of power, may produce an amount 0 ma原创 2018-02-05 19:52:11 · 217 阅读 · 0 评论 -
Minimum Cost (最小费用最大流)
地址:点击打开链接Dearboy, a goods victualer, now comes to a big problem, and he needs your help. In his sale area there are N shopkeepers (marked from 1 to N) which stocks goods from him.Dearboy has M s原创 2018-02-05 17:01:33 · 444 阅读 · 0 评论 -
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 free flow of information and id原创 2018-02-05 15:49:28 · 159 阅读 · 0 评论 -
Going Home (费用流)
地址:点击打开链接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原创 2018-02-05 14:18:33 · 165 阅读 · 0 评论 -
Harry Potter and the Forbidden Forest(最大流 +最小割 最小边)
Harry Potter notices some Death Eaters try to slip into Castle. The Death Eaters hide in the most depths of Forbidden Forest. Harry need stop them as soon as. The Forbidden Forest is mysterious. It co...原创 2018-02-09 16:32:10 · 302 阅读 · 0 评论 -
Marriage Match IV (最大流+最短路+Dijkstra)
Do not sincere non-interference。 Like that show, now starvae also take part in a show, but it take place between city A and B. Starvae is in city A and girls are in city B. Every time starvae can get ...原创 2018-02-09 15:26:04 · 361 阅读 · 0 评论 -
Food (最大流)
地址:点击打开链接 类似于 POJ 3281 Dining,属同一类型题目。 You, a part-time dining service worker in your college’s dining hall, are now confused with a new problem: serve as many people as possible. The iss原创 2018-02-05 11:21:35 · 145 阅读 · 0 评论 -
Tour (最小费用流:有向环覆盖+拆点)
地址:点击打开链接In the kingdom of Henryy, there are N (2 <= N <= 200) cities, with M (M <= 30000) one-way roads connecting them. You are lucky enough to have a chance to have a tour in the kingdom. ...原创 2018-02-08 21:34:17 · 251 阅读 · 0 评论 -
Bomb (强连通+缩点)
There are NN bombs needing exploding. Each bomb has three attributes: exploding radius riri, position (xi,yi)(xi,yi) and lighting-cost cici which means you need to pay cici cost making i原创 2018-01-28 11:40:42 · 278 阅读 · 0 评论 -
Island Transport (最大流+ISAP)
In the vast waters far far away, there are many islands. People are living on the islands, and all the transport among the islands relies on the ships. You have a transportation company there. Som原创 2018-02-05 22:19:03 · 185 阅读 · 0 评论 -
Sabotage (最小割 最大流)
地址:点击打开链接The regime of a small but wealthy dictatorship has been abruptly overthrown by an unexpected rebellion.Because of the enormous disturbances this is causing in world economy, an imperialist原创 2018-02-06 15:40:44 · 197 阅读 · 0 评论 -
2018年全国多校算法寒假训练营练习比赛(第四场)
地址:点击打开链接A 石油采集思路:二维矩阵四连通图是一个二分图,其实仔细想想就是将相邻的“#”建图,然后在找最大匹配。匈牙利算法即可。也可以dfs,代码如下:匈牙利:#include<iostream>#include<stdlib.h>#include<cstdio>#include<cstring>#include<string&...原创 2018-02-11 22:13:50 · 268 阅读 · 0 评论 -
#1467 : 2-SAT·hihoCoder音乐节
#1467 : 2-SAT·hihoCoder音乐节时间限制:10000ms单点时限:1000ms内存限制:256MB描述hihoCoder音乐节由hihoCoder赞助商大力主办,邀请了众多嘉宾和知名乐队参与演出。音乐会分为上午、下午两场进行,主办方指定了n首歌让乐队进行演唱。每首歌只会被演唱一次,要么在上午要么在下午。参加音乐会的嘉宾们对于歌曲的演唱时间有一些要求。具体来说,每位嘉宾会指定两首...原创 2018-03-20 22:36:44 · 132 阅读 · 0 评论 -
hihoCoder_#1183_连通性一·割边与割点
时间限制:10000ms单点时限:1000ms内存限制:256MB描述还记得上次小Hi和小Ho学校被黑客攻击的事情么,那一次攻击最后造成了学校网络数据的丢失。为了避免再次出现这样的情况,学校决定对校园网络进行重新设计。学校现在一共拥有N台服务器(编号1..N)以及M条连接,保证了任意两台服务器之间都能够通过连接直接或者间接的数据通讯。当发生黑客攻击时,学校会立刻切断网络中的一条连接或是立刻关闭一台...原创 2018-03-18 16:27:24 · 149 阅读 · 0 评论 -
#1181 : 欧拉路·二 (输出点)
#1181 : 欧拉路·二时间限制:10000ms单点时限:1000ms内存限制:256MB描述在上一回中小Hi和小Ho控制着主角收集了分散在各个木桥上的道具,这些道具其实是一块一块骨牌。主角继续往前走,面前出现了一座石桥,石桥的尽头有一道火焰墙,似乎无法通过。小Hi注意到在桥头有一张小纸片,于是控制主角捡起了这张纸片,只见上面写着:将M块骨牌首尾相连放置于石桥的凹糟中,即可关闭火焰墙。切记骨牌需...原创 2018-03-18 14:38:07 · 172 阅读 · 0 评论 -
#1176 : 欧拉路·一
#1176 : 欧拉路·一时间限制:10000ms单点时限:1000ms内存限制:256MB描述小Hi和小Ho最近在玩一个解密类的游戏,他们需要控制角色在一片原始丛林里面探险,收集道具,并找到最后的宝藏。现在他们控制的角色来到了一个很大的湖边。湖上有N个小岛(编号1..N),以及连接小岛的M座木桥。每座木桥上各有一个宝箱,里面似乎装着什么道具。湖边还有一个船夫,船夫告诉主角。他可以载着主角到任意一...原创 2018-03-18 13:58:12 · 156 阅读 · 0 评论 -
#1122 : 二分图二•二分图最大匹配之匈牙利算法
时间限制:10000ms单点时限:1000ms内存限制:256MB描述上一回我们已经将所有有问题的相亲情况表剔除了,那么接下来要做的就是安排相亲了。因为过年时间并不是很长,所以姑姑希望能够尽可能在一天安排比较多的相亲。由于一个人同一天只能和一个人相亲,所以要从当前的相亲情况表里选择尽可能多的组合,且每个人不会出现两次。不知道有没有什么好办法,对于当前给定的相亲情况表,能够算出最多能同时安排多少组相...原创 2018-03-18 08:41:38 · 220 阅读 · 0 评论 -
Marriage Match II (最大流 +二分 +并查集)
题意: 有N个女孩要与N个男孩玩配对游戏.每个女孩有一个可选男孩的集合(即该女孩可以选自己集合中的任意一个男孩作为该轮的搭档).然后从第一轮开始,每个女孩都要和一个不同的男孩配对.如果第一轮N个女孩都配对成功,那么就开始第二轮配对,女孩依然从自己的备选男孩集合中选择,但是不能选那些已经被该女孩在前几轮选择中选过的男孩了(比如i女孩在第一轮选了j男孩,那么i在第二轮就不能选j男孩了). 问你游戏最多...原创 2018-02-08 17:10:15 · 225 阅读 · 0 评论 -
Leapin' Lizards (最大流+Dinic+拆点)
Your platoon of wandering lizards has entered a strange room in the labyrinth you are exploring. As you are looking around for hidden treasures, one of the rookies steps on an innocent-looking stone a...原创 2018-02-07 22:34:21 · 274 阅读 · 0 评论 -
方格取数(2) (最大独立集+最大流+网络流)
给你一个m*n的格子的棋盘,每个格子里面有一个非负数。 从中取出若干个数,使得任意的两个数所在的格子没有公共边,就是说所取数所在的2个格子不能相邻,并且取出的数的和最大。Input包括多个测试实例,每个测试实例包括2整数m,n和m*n个非负数(mOutput对于每个测试实例,输出可能取得的最大的和Sample Input3 375 15 21 75 15 28 34原创 2018-02-07 10:46:09 · 579 阅读 · 0 评论 -
Control (最大流+Dinic+拆点)
You, the head of Department of Security, recently received a top-secret information that a group of terrorists is planning to transport some WMD 1 from one city (the source) to another one (the destin原创 2018-02-06 22:37:18 · 170 阅读 · 0 评论 -
ACM Computer Factory (最大流+Dinic+输出路径+拆点)
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原创 2018-02-06 21:37:05 · 217 阅读 · 0 评论 -
Escape(最大流+ISAP+状态压缩)
2012 If this is the end of the world how to do? I do not know how. But now scientists have found that some stars, who can live, but some people do not fit to live some of the planet. Now scientists wa原创 2018-02-06 17:36:33 · 201 阅读 · 0 评论 -
The Best Path(欧拉回路—+路径)
Alice is planning her travel route in a beautiful valley. In this valley, there are NN lakes, and MM rivers linking these lakes. Alice wants to start her trip from one lake, and enjoys the landsca原创 2018-01-27 21:32:19 · 253 阅读 · 0 评论 -
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原创 2018-01-25 21:02:40 · 167 阅读 · 0 评论 -
Proving Equivalences (有向图强连通+等价性证明)
Consider the following exercise, found in a generic linear algebra textbook. Let A be an n × n matrix. Prove that the following statements are equivalent: 1. A is invertible. 2. Ax = b has e原创 2018-01-25 19:58:32 · 633 阅读 · 0 评论 -
Catenyms(有向欧拉图+判断回路+打印路径)
A catenym is a pair of words separated by a period such that the last letter of the first word is the same as the last letter of the second. For example, the following are catenyms: dog.gophergoph原创 2018-01-25 19:00:00 · 235 阅读 · 0 评论 -
P1345 [USACO5.4]奶牛的电信Telecowmunication(网络流+拆点)
地址:点击打开链接总结:拆点,顾名思义,就是把一个点拆成两个点。因为在网络流的模型中,割特指边集而非点集,所以想要实现“可以被割掉的点”,就用用到拆点思想。另外,这种方法也可以被理解为:使点同边一样有一个容量上限。把点A分成两个,一个叫A1,表示A的“入点”;另一个叫A2,表示A的“出点”。A的所有出边都从A2连出,所有入边都连向A1。再连一条边从A1指向A2,其边权为点A的“点容量”。原创 2018-02-01 20:01:55 · 174 阅读 · 0 评论 -
POJ 2391 Ombrophobic Bovines(二分+floyd+拆点+Dinic网络流)
题意:有n个田地,给出每个田地上初始的牛的数量和每个田地可以容纳的牛的数量。m条双向的路径,每条路径上可以同时通过的牛没有限制。问牛要怎么走,能在最短时间内使得每块田地都能容纳的下,输出最短时间或-1。分析:先floyd求出任意两点之间的最短距离,然后二分答案,判断是否可以在时间不超过mid的情况下完成移动:建图:每个点拆成两个点x(i)和x'(i+n),源点向x连原创 2018-02-01 18:00:25 · 168 阅读 · 0 评论 -
poj1149 - PIGS(最大流)
地址:点击打开链接题意:有 M 个猪圈,每个猪圈里初始时有若干头猪。一开始所有猪圈都是关闭的。依 次来了 N 个顾客,每个顾客分别会打开指定的几个猪圈,从中买若干头猪。每 个顾客分别都有他能够买的数量的上限。每个顾客走后,他打开的那些猪圈中的 猪,都可以被任意地调换到其它开着的猪圈里,然后所有猪圈重新关上。问总共 最多能卖出多少头猪。(1 举个例子来说。有 3 个猪圈,初始时分别有 3、原创 2018-02-01 16:51:06 · 160 阅读 · 0 评论 -
Network of Schools (强连通分量)
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原创 2018-01-25 15:28:14 · 181 阅读 · 0 评论 -
Ant Trip (一笔画问题)
Ant 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 road , and e原创 2018-01-25 11:16:59 · 984 阅读 · 0 评论 -
欧拉回路 (模板题,判断是否存在欧拉回路)
N - 欧拉回路 思路:使用并查集+degree处理,用并查集寻找每个连通分量的根节点,degree用来记录每个节点的度,注意无向图欧拉回路存在的条件是度全为偶数!!代码:#include #include #include #include #include #include #include #include #define ll lon原创 2018-01-25 11:03:49 · 1749 阅读 · 0 评论 -
Codeforces Round #460 (Div. 2)
C. Seat Arrangementstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputSuppose that you are in a campus and ha原创 2018-02-01 10:08:47 · 329 阅读 · 0 评论 -
有向图的强连通分量
参考:刘汝佳,训练指南饶齐 http://blog.csdn.net/u013480600/article/details/44852835SCC的Tarjan算法代码:#include#include#include#include#includeusing namespace std;const int maxn=1000+10;int n,m; //点数,边数in原创 2018-01-22 17:27:06 · 138 阅读 · 0 评论 -
Window Pains (拓扑排序)
Boudreaux likes to multitask, especially when it comes to using his computer. Never satisfied with just running one application at a time, he usually runs nine applications, each in its own window. Du原创 2018-01-26 10:09:11 · 440 阅读 · 0 评论 -
John's trip (欧拉回路判断+字典序输出)
题意:给你一个无向图,数据格式如点x 点y 边Z,表示由x点和y点构成了Z边。现在要问你该图中是否存在欧拉回路,如果存在,则输出字典序最小的那条欧拉回路(输入按序走过的所有边标号)。且题目中保证了该无向图是连通。思路:使用欧拉路径输出模板来进行输出即可。然后要保证从John的家作为起始点输出欧拉回路且保证字典序最小,因为euler这个函数输出的欧拉路径是从起点逆序的(即起点被放到了最后原创 2018-01-26 10:57:56 · 453 阅读 · 0 评论 -
hdu 3667 Transportation(最小费用最大流+拆边)
题意:求从城市1运送K单位物品到城市n的最小花费。给定的有向边,每条边都有其容量c,并且,产生的费用是 a * ( f * f ),其中f是这条边上的流量,a是给出的系数。思路:这个题目就是刘汝佳训练指南上建模与建图的一种,费用与流量的平方成正比的最小流。容量c均为整数,并且每条弧还有一个费用系数a,表示该弧流量为x时费用为a*x*x,如何求最小费用最大流?用拆边法,如图图原创 2018-02-02 10:36:30 · 284 阅读 · 0 评论 -
Caocao's Bridges(重边无向图求桥)
Caocao was defeated by Zhuge Liang and Zhou Yu in the battle of Chibi. But he wouldn't give up. Caocao's army still was not good at water battles, so he came up with another idea. He built many island原创 2018-01-27 20:08:27 · 322 阅读 · 0 评论