
🐖图论相关算法
文章平均质量分 56
🐖图论相关算法
风骨散人Chiam
我叫风骨散人Chiam,名字的意思是向往可以不低头的自由生活,可现实却不是这样,希望同样被生活绑架的你,可以通过自己的努力改变现状。目前在中国科学院攻读研究生,研究方向是网络安全和控制访问,热爱编程,热爱技术,喜欢分享,知识无界,希望我的分享可以帮到你!
如果有什么想看的,可以私信我,如果在能力范围内,我会发布相应的博文!
感谢大家的阅读!你的点赞、收藏、关注是对我最大的鼓励!
在CSDN没什么收益,博主已经没有动力继续更新技术文章了,已经准备跑路了,大家如果想了解我的更改情况就去我的主页看看。
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
图论--边双连通V-DCC缩点
// tarjan算法求无向图的割点、点双连通分量并缩点#include<iostream>#include<cstdio>#include<cstring>#include<algorithm>#include<vector>using namespace std;const int SIZE = 100010;int...原创 2019-10-24 16:33:01 · 2760 阅读 · 0 评论 -
图论--双连通E-DCC缩点模板
// tarjan算法求无向图的桥、边双连通分量并缩点#include<iostream>#include<cstdio>#include<cstring>#include<algorithm>#include<vector>using namespace std;const int SIZE = 100010;int ...原创 2019-10-24 16:31:44 · 2699 阅读 · 0 评论 -
图论--最小环--Floyd模板
#include <iostream>#include <algorithm>#include <cstdio>#include <cstring>#include <vector>#include <map>#include <stack>using namespace std;const in...原创 2019-10-23 15:35:24 · 2737 阅读 · 0 评论 -
图论--LCA--Tarjan(离线)
* * 给出一颗有向树,Q个查询 * 输出查询结果中每个点出现次数 * 复杂度O(n + Q); */const int MAXN = 1010;const int MAXQ = 500010; // 查询数的最大值// 并查集部分int F[MAXN]; // 需要初始化为-1int find(int x){ if...原创 2019-10-23 15:31:41 · 2706 阅读 · 0 评论 -
图论——Tarjan 初步 DFS序+时间戳+欧拉序
一、什么是DFS序:DFS序是按照先序遍历,先遍历根节点然后依次遍历左子树,右子树的过程,每次遇到新的节点就把新访问节点加到序列中,代码如下:int DFSrk[100000];int cnt=0;int dfs(int u,int fa){ DFSrk[cnt++]=u; for(int i=head[u];i;i=ege[i].next) { ...原创 2019-10-05 20:42:03 · 3032 阅读 · 0 评论 -
图论--LCA--在线RMQ ST
板子测试POJ1330,一发入魂,作者是KuangBin神犇,感谢????#include <cstdio>#include <cstring>#include <algorithm>using namespace std;const int MAXN = 10010;int rmq[2 * MAXN]; // rmq数组,就是...原创 2019-10-05 15:36:34 · 2679 阅读 · 0 评论 -
图论--最小生成树--Kruscal 模板
#include<iostream>#include<queue>#include<algorithm>#include<set>#include<cmath>#include<vector>#include<map>#include<stack>#include<bitset&...原创 2019-09-19 22:01:15 · 2677 阅读 · 0 评论 -
图论--(技巧)超级源点与超级汇点
背景:给出题目,在一张图中有多个点起点,一个终点,求所有起点到终点的最短距离。解题方法:1.跑N边单源最短路,但是这样是不行的肯定超时。2.floyd求出所有最短路,枚举每个起点到终点的距离,这个似乎比法1更慢。3.反向建边,反向跑一遍Dijkstra,或者SPFA,这样就能求到终点到起点的距离,在枚举最小的一个即可,时间复杂度为一遍最短路加枚举N。4.建立超级源点,虚拟出一个...原创 2019-08-29 15:24:06 · 3673 阅读 · 0 评论 -
Codeforce 263D Cycle in Graph 搜索 图论 哈密尔顿环
You've got a undirected graphG, consisting ofnnodes. We will consider the nodes of the graph indexed by integers from 1 ton. We know that each node of graphGis connected by edges with at leastk...原创 2019-08-22 16:58:41 · 2559 阅读 · 0 评论 -
图论-最长路--关于最长路的探讨2
之前我们说完最长路的算法,这里我们进一步的补充!关于最长路,我们想一下如果是有向有环图,那么如果不存在负权的话,那么这个题是不可解的,因为在正环上一直走,路径无限大,那么也就是说,当为正权的时候一定无环,就可以转化为AOE关键路径问题,拓扑排序做,会快很多。其次是负权及无向图时,可以用SPFA进行求解。...原创 2019-12-05 14:40:07 · 2829 阅读 · 0 评论 -
图论--2-SAT--HDOJ/HDU 1824 Let's go home
Problem Description小时候,乡愁是一枚小小的邮票,我在这头,母亲在那头。—— 余光中集训是辛苦的,道路是坎坷的,休息还是必须的。经过一段时间的训练,lcy决定让大家回家放松一下,但是训练还是得照常进行,lcy想出了如下回家规定,每一个队(三人一队)或者队长留下或者其余两名队员同时留下;每一对队员,如果队员A留下,则队员B必须...原创 2019-11-17 10:04:11 · 2635 阅读 · 0 评论 -
图论--2-SAT--POJ Ikki's Story IV - Panda's Trick
Descriptionliympanda, one of Ikki’s friend, likes playing games with Ikki. Today after minesweeping with Ikki and winning so many times, he is tired of such easy games and wants to play another g...原创 2019-11-17 10:01:16 · 2621 阅读 · 0 评论 -
图论--2-SAT--HDU/HDOJ 4115 Eliminate the Conflict
Problem DescriptionConflicts are everywhere in the world, from the young to the elderly, from families to countries. Conflicts cause quarrels, fights or even wars. How wonderful the world will be if ...原创 2019-11-17 09:53:38 · 2605 阅读 · 0 评论 -
图论--2-SAT--HDU/HDOJ 1814 Peaceful Commission
Peaceful CommissionTime Limit: 10000/5000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2775Accepted Submission(s): 865Problem DescriptionThe Public Peace...原创 2019-11-17 09:50:35 · 2639 阅读 · 0 评论 -
图论--2-SAT--暴力染色法求字典序最小模版
#include <cstdio>#include <cstring>#include <stack>#include <queue>#include <vector>#include <algorithm>#define MAXN 40000+10#define MAXM 200000+10#define ...原创 2019-11-17 09:43:39 · 2680 阅读 · 0 评论 -
图论--2-SAT--Ligthoj 1407 Explosion 三元关系枚举
Planet Krypton is about to explode. The inhabitants of this planet have to leave the planet immediately. But the problem is that, still some decisions have to be made - where to go, how to go etc. So,...原创 2019-11-17 09:42:11 · 2624 阅读 · 0 评论 -
图论--2-SAT--POJ 3905 Perfect Election
Perfect ElectionTime Limit:5000MS Memory Limit:65536KTotal Submissions:964 Accepted:431DescriptionIn a country (my memory fails to say which), the candidates {1, 2 ..., N} are...原创 2019-11-17 09:23:23 · 2636 阅读 · 0 评论 -
图论--2-SAT--暴力染色法模板(字典序最小解) RQ的板子
//暴力DFS,求字典序最小的解,也是求字典序唯一的方法#include<cstdio>#include<cstring>#include<vector>using namespace std;const int maxn=10000+10;struct TwoSAT{ int n;//原始图的节点数(未翻倍) vector<...原创 2019-11-15 22:01:32 · 2840 阅读 · 2 评论 -
图论--2-SAT--poj 3678-Katu Puzzle(模板题)
DescriptionKatu Puzzle is presented as a directed graphG(V,E) with each edgee(a,b) labeled by a boolean operatorop(one of AND, OR, XOR) and an integerc(0 ≤c≤ 1). One Katu is solvable if o...原创 2019-11-15 21:46:15 · 2680 阅读 · 0 评论 -
图论--拓扑排序--HDU-1285确定比赛名次
Problem Description有N个比赛队(1<=N<=500),编号依次为1,2,3,。。。。,N进行比赛,比赛结束后,裁判委员会要将所有参赛队伍从前往后依次排名,但现在裁判委员会不能直接获得每个队的比赛成绩,只知道每场比赛的结果,即P1赢P2,用P1,P2表示,排名时P1在P2之前。现在请你编程序确定排名。Input输入有若干组,每组中的第一行为二个数N(1<=...原创 2019-12-10 10:27:58 · 2603 阅读 · 0 评论 -
图论--2-SAT--Tarjan连通分量+拓扑排序O(N+M)模板
#include <cstdio>#include <cstring>#include <queue>#include <vector>#include <stack>#include <algorithm>#define MAXN 2000+10#define MAXM 400000#define INF ...原创 2019-11-15 21:47:47 · 2707 阅读 · 0 评论 -
拓扑排序
在图论中,拓扑排序(Topological Sorting)是一个有向无环图(DAG, Directed Acyclic Graph)的所有顶点的线性序列。且该序列必须满足下面两个条件:每个顶点出现且只出现一次。若存在一条从顶点 A 到顶点 B 的路径,那么在序列中顶点 A 出现在顶点 B 的前面。有向无环图(DAG)才有拓扑排序,非DAG图没有拓扑排序一说。从 DAG 图中选择一个 ...原创 2019-08-31 00:04:35 · 3180 阅读 · 0 评论 -
图论--网络流--最大流 洛谷P4722(hlpp)
题目描述给定nn个点,mm条有向边,给定每条边的容量,求从点ss到点tt的最大流。输入格式第一行包含四个正整数nn、mm、ss、tt,用空格分隔,分别表示点的个数、有向边的个数、源点序号、汇点序号。接下来mm行每行包含三个正整数u_iui、v_ivi、c_ici,用空格分隔,表示第ii条有向边从u_iui出发,到达v_ivi,容量为c_ici输出格式...原创 2019-11-10 12:06:12 · 2704 阅读 · 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...原创 2019-11-10 11:54:24 · 2632 阅读 · 0 评论 -
图论--网络流--费用流--POJ 2156 Minimum Cost
DescriptionDearboy, 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 sup...原创 2019-11-10 10:48:51 · 2625 阅读 · 0 评论 -
图论--网络流--最大流 HDU 2883 kebab(离散化)
Problem DescriptionAlmost everyone likes kebabs nowadays (Here a kebab means pieces of meat grilled on a long thin stick). Have you, however, considered about the hardship of a kebab roaster while e...原创 2019-11-05 17:23:13 · 2642 阅读 · 0 评论 -
图论--网络流--最大流--POJ 1698 Alice's Chance
DescriptionAlice, a charming girl, have been dreaming of being a movie star for long. Her chances will come now, for several filmmaking companies invite her to play the chief role in their new films...原创 2019-11-04 22:06:18 · 2630 阅读 · 0 评论 -
图论--网络流--最大流 POJ 2289 Jamie's Contact Groups (二分+限流建图)
DescriptionJamie is a very popular girl and has quite a lot of friends, so she always keeps a very long contact list in her cell phone. The contact list has become so long that it often takes a long...原创 2019-11-04 21:32:41 · 3186 阅读 · 0 评论 -
图论--网络流--最小费用流最大流模板
#include<cstdio>#include<cstring>#include<algorithm>#include<queue>#include<vector>#define INF 1e9using namespace std;const int maxn= 1000+10; struct Edge{ ...原创 2019-11-03 23:50:46 · 2637 阅读 · 0 评论 -
网络流--最大流--POJ 1459 Power Network
#include<cstdio>#include<cstring>#include<algorithm>#include<queue>#include<vector>#define INF 1e9using namespace std;const int maxn=100+5; struct Edge{ in...原创 2019-11-03 13:50:05 · 2612 阅读 · 0 评论 -
网络流--最大流--POJ 1273 Drainage Ditches
链接DescriptionEvery time it rains on Farmer John's fields, a pond forms over Bessie's favorite clover patch. This means that the clover is covered by water for awhile and takes quite a long time to...原创 2019-11-02 15:14:32 · 2596 阅读 · 0 评论 -
网络流--最大流--HDU 3549 Flow Problem
题目链接Problem DescriptionNetwork flow is a well-known difficult problem for ACMers. Given a graph, your task is to find out the maximum flow for the weighted directed graph.InputThe first line ...原创 2019-11-02 15:08:15 · 2620 阅读 · 0 评论 -
图论-网络流-Dinic (邻接表版)
//RQ的板子真的很好用#include<cstdio>#include<cstring>#include<queue>#define INF 1e9using namespace std;const int maxn=200+5; struct Edge{ int from,to,cap,flow; Edge(){} ...原创 2019-11-01 22:42:46 · 2725 阅读 · 0 评论 -
网络流--最大流--hlpp(预流推进)模板
//500ms 秒掉洛谷推流问题#include <algorithm>#include <iostream>#include <cstring>#include <vector>#include <queue>using namespace std;typedef long long LL;typedef long l...原创 2019-11-01 15:05:40 · 2772 阅读 · 0 评论 -
网络流--最大流--Dinic模板矩阵版(当前弧优化+非当前弧优化)
//非当前弧优化版#include <iostream>#include <cstdio>#include <math.h>#include <cstring>#include <queue>#define INF 0x3f3f3f3fusing namespace std;int tab[250][250];//邻接矩...原创 2019-10-31 22:01:22 · 2665 阅读 · 0 评论 -
图论-网络流-最大流--POJ1273Drainage Ditches(Dinic)
Drainage DitchesTime Limit:1000MS Memory Limit:10000K Total Submissions:91585 Accepted:35493 DescriptionEvery time it rains on Farmer John's fields, a pond forms over Bessi...原创 2019-10-31 21:58:36 · 2636 阅读 · 0 评论 -
网络流--最大流--EK模板
#include <iostream>#include <cstdio>#include <cstring>#include <cmath>#include <algorithm>#include <vector>#include <set>#include <map>#include...原创 2019-10-28 22:28:56 · 2687 阅读 · 0 评论 -
图论--拓扑排序--判断是否为DAG图
#include<cstdio>#include<cstring>#include<vector>#include<queue>using namespace std;const int maxn=100+10;int n,m;vector<int> G[maxn];//G[i]表示i节点所指向的所有其他点int in[...原创 2019-11-20 15:31:53 · 2776 阅读 · 0 评论 -
图论--拓扑排序--判断一个图能否被拓扑排序
拓扑排序的实现条件,以及结合应用场景,我们都能得到拓扑排序适用于DAG图(Directed Acyclic Graph简称DAG)有向无环图,根据关系我们能得到一个线性序列,实现的方式是DFS,具体的实现原理,我们将在下一篇博客中讲解。#include<cstdio>#include<cstring>#include<vector>#include...原创 2019-11-20 15:30:37 · 3265 阅读 · 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 s...原创 2019-11-18 21:01:16 · 2694 阅读 · 0 评论