随笔分类 - 图论
摘要:1 /* 2 Dijkstra的算法思想: 3 在所有没有访问过的结点中选出dis(s,x)值最小的x 4 对从x出发的所有边(x,y),更新 5 dis(s,y)=min(dis(s,y),dis(s,x)+dis(x,y)) 6 */ 7 #include <iostream> 8 #include <cstdio> 9 #include <queue>10 #include <vector>11 using namespace std;12 const int Ni = 10000;13 const int INF = 1<<2
        阅读全文
            
摘要:1 #include <cstdio> 2 #include <iostream> 3 using namespace std; 4 const int Ni = 505; 5 const int n = 500; 6 int eg[Ni][Ni]; 7 int deg[Ni],pos; 8 int path[Ni*5]; 9 void dfs(int s)10 {11 if(deg[s])12 for(int i=1;i<=n;i++) if(eg[s][i])13 {14 eg[s][i]--;15 ...
        阅读全文
            
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=4360 1 #include <iostream> 2 #include <vector> 3 #include <queue> 4 #include <cstdio> 5 using namespace std; 6 const long long inf = 1ll<<57; 7 const int Ni = 1320*2; 8 struct node{ 9 int v,w,e;10 node(){}11 node(int a,int b,int
        阅读全文
            
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1599网上找到的Floyd求最小环模板 1 #include <cstdio> 2 #include <algorithm> 3 using namespace std; 4 const int Ni=105; 5 const int INF=10000000; 6 7 int dist[Ni][Ni],g[Ni][Ni]; 8 int fa[Ni][Ni],path[Ni]; 9 10 int n,m,num,minc;11 12 void Floyd()13 {14 int i,j
        阅读全文
            
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=3038 1 /* 2 题意: 3 对于特定的一个长n的数字序列,给出m个条件,形式为:a b sum意义如下 4 [a,b]闭区间里的所有数字的和为sum 5 问这m个条件中有多少不合理的。如 6 1 5 10 7 6 10 20 8 1 10 20 9 这3个条件中第三个为不合理的,因为由前两个的可以知道1 10为3010 (注:先出现的视为合理,我们不说1 5 10不合理)11 */12 #include <iostream>13 #include <cstdio>14 #incl
        阅读全文
            
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1532 1 #include <iostream> 2 #include <cstdio> 3 #include <climits> 4 #include <cstring> 5 #include <algorithm> 6 using namespace std; 7 typedef struct {int v,next,val;} edge; 8 const int MAXN=20010; 9 const int MAXM=500010; 10 
        阅读全文
            
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1532 1 #include<cstdio> 2 #include<cstring> 3 #include<queue> 4 #include<cmath> 5 using namespace std; 6 const int Ni = 210; 7 const int MAX = 1<<26; 8 struct Edge{ 9 int u,v,c;10 int next;11 }edge[20*Ni];12 int n,m;13 int edn;/
        阅读全文
            
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1384 1 #include <iostream> 2 #include <cstring> 3 #include <queue> 4 #include <cstdio> 5 using namespace std; 6 const int N = 50000+10; 7 const int INF = 1<<27; 8 int n,max_n,min_n,cnt; 9 bool vis[N];10 int dis[N];11 int root[N]
        阅读全文
            
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=2063 1 #include <iostream> 2 #include <cstdio> 3 #include <cstring> 4 using namespace std; 5 const int N = 500+10; 6 int gil,boy; 7 int gil_boy[N][N]; 8 int flg[N];//在递归过程中男生N是否有女朋友 9 int bg[N];//男生N的女朋友10 //匈牙利算法11 int xfind(int g)//女生g找男朋
        阅读全文
            
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1811 1 #include <iostream> 2 #include <cstring> 3 #include <vector> 4 #include <queue> 5 #include <cstdio> 6 #include <algorithm> 7 using namespace std; 8 const int N=10000+10; 9 int n,m;10 int p[N],in[N];11 int arr[N],brr
        阅读全文
            
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1142dijkstra(邻接矩阵) 1 #include <cstdio> 2 #include <cstring> 3 #include <iostream> 4 using namespace std; 5 const int INF=1<<29; 6 const int MAXN=1000+5; 7 int v[MAXN],d[MAXN]; 8 int w[MAXN][MAXN]; 9 int n,m;10 void dijkstra()11 {12 me
        阅读全文
            
 
                    
                
 
 浙公网安备 33010602011771号
浙公网安备 33010602011771号