随笔分类 -  图论

摘要:水题,不解释View Code #include<stdio.h>#include<string.h>const int INF = 9999999;int n,r,map[250][250];char city[250][30];int num;int max(int a,int b){ return a>b?a:b;}int min(int a,int b){ return a<b?a:b;}int find(char s[]){ int i; for(i=0;i<num;i++) if(strcmp(city[i],s)==0) ... 阅读全文
posted @ 2011-09-14 14:48 Because Of You 阅读(139) 评论(0) 推荐(0) 编辑
摘要:View Code #include<stdio.h>#include<stdlib.h>#include<math.h>#include<string.h>#define maxn 1005const int inf =1000000000;struct Edge{ int u,v; __int64 cost;}E[maxn*maxn];int nv,ne;int pre[maxn],ID[maxn],vis[maxn];__int64 In[maxn];int ansi;//最小树形图邻接表版本,三步走,找最小入弧,找有向环,缩环为点__in 阅读全文
posted @ 2011-09-07 12:54 Because Of You 阅读(991) 评论(0) 推荐(1) 编辑
摘要:需要注意,因为增加一个零点,最后总点数要加1;此模板的边和点都从0开始计数废话一句,厚积方能薄发啊。View Code #include<stdio.h>#include<stdlib.h>#include<math.h>#include<string.h>#define maxn 1005const int inf =1000000000;struct Edge{ int s,t; int cost;}edge[maxn*maxn];struct node{ int x,y,z;}a[maxn];int E,nv,ne;int pre[maxn 阅读全文
posted @ 2011-09-06 20:07 Because Of You 阅读(320) 评论(0) 推荐(0) 编辑
摘要:记住,这是china算法,呵呵,一丝悲哀,又有一丝欣慰第一次做,用的是矩阵版本的,但貌似对于数据更大的情况要用邻接表的,继续学习View Code #include<stdio.h>#include<math.h>#include<string.h>#define INF 100000000#define min(a,b) a<b?a:bint n,m;double map[110][110];int vis[110],pre[110];int circle[110]; struct { int x,y;}node[110];double dist(i 阅读全文
posted @ 2011-09-06 11:44 Because Of You 阅读(289) 评论(0) 推荐(0) 编辑