随笔分类 - 图论
摘要:差分约束基本思想:给出一些不等式,最后询问这些不等式是否能够同时成立 首先要将不等式换成dis(a)-dis(b)<=k的形式, 然后建立从b到a长度为k的边, 最后利用spfa求一遍最短路,判断是否有负环,即可 如果有负环,则说明该不等式组不能同时成立 spfa模版:
阅读全文
摘要:twoset基本思想:有n个党派,每个党派有2个人,要求每个党派都要选出一个人,每个人之间可能存在互斥关系,判断最后能否选出这N个人来
阅读全文
摘要:const int MAXN=5010; const int MAXM=2500000; struct Edge { int to,next; }edge[MAXM]; int head[MAXN],tot; int Low[MAXN],DFN[MAXN],Stack[MAXN],Belong[MAXN]; int Index,top; int scc; bool Instack[M...
阅读全文
摘要:1 #include 2 #include 3 #include 4 5 using namespace std; 6 7 int num; 8 int head[20010]; 9 int dp[20010];10 int val[20010];11 int n;12 13 struc...
阅读全文
摘要:1 #include 2 #include 3 #include 4 5 using namespace std; 6 7 int dp[1510][2]; 8 int head[1510]; 9 bool in[1510];10 int num;11 12 struct edge13 ...
阅读全文
摘要:1 #include 2 #include 3 #include 4 5 using namespace std; 6 7 int val[100100]; 8 int head[100100]; 9 int dp[100100];10 int num;11 bool in[100010...
阅读全文
摘要:在一个有向图中,路径覆盖就是在图中找一些路经,使之覆盖了图中的所有顶点,且任何一个顶点有且只有一条路径与之关联最小路径数 = 总点数 – 最大匹配数 1 #include 2 #include 3 #include 4 #include 5 6 using namespace std; 7...
阅读全文
摘要:图的独立集:寻找一个点集,其中任意两点在图中无对应边二分图的最大独立集=图的点数-最大匹配数 1 #include 2 #include 3 #include 4 #include 5 6 using namespace std; 7 8 struct people 9...
阅读全文
摘要:1 #include 2 #include 3 #include 4 #include 5 6 using namespace std; 7 8 struct edge 9 {10 int fro,to,val;11 }e[30000];12 int ednum=0;13 in...
阅读全文
摘要:1 #include 2 #include 3 #include 4 5 using namespace std; 6 7 struct edge 8 { 9 int fro,to,next;10 }e[100010];11 int map[110][110];12 bool v...
阅读全文
摘要:1 #include 2 #include 3 #include 4 #include 5 #include 6 7 using namespace std; 8 9 int map[110][110];10 bool vis[110];11 int div1[110];12 int...
阅读全文
摘要:第一种克鲁斯卡尔算法(并查集) 1 #include 2 #include 3 #include 4 #include 5 #include 6 7 using namespace std; 8 9 struct edge10 {11 int fro,to,val,sta;12...
阅读全文
摘要:第一种迪杰斯特拉算法求最短路(时间复杂度为(n*n)) 要求边的权值为正数 1 #include <iostream> 2 #include <cstdio> 3 #include <cstring> 4 5 using namespace std; 6 7 int t,n; 8 int map[1
阅读全文

浙公网安备 33010602011771号