uva 10369【Arctic Network】
摘要:模板题目了,又一个Krustral变形。。。题意:给你P个点,目前有S个卫星频道(satellite channels),求一条边在连接后中的图中是最大的,但是要求是所用方案中最小的,明显的最小生成树。求最小生成树中最长的那条边就可以了,但是那些最长的边可以卫星通讯(Any two outposts with a satellite channel can communicate via the satellite,其实这里还是有一个疑问的:要是a,b用卫星频道,c,d也用卫星频道,那么如果这两段不用radio是不是也可以通讯啊,根据题意应该是不可以的,如果可以就A不了了),所以求第P-S条最
阅读全文
posted @
2012-04-16 16:42
Shirlies
阅读(636)
推荐(1)
uva 10397【Connect the Campus】
摘要:Krustral 变形。。。。。。代码如下: 1 #include <cstdio> 2 #include <cstring> 3 #include <algorithm> 4 #include <cmath> 5 6 struct distance 7 { 8 int u,v; 9 double w;10 }d[1000000];11 12 struct point13 {14 int x,y;15 }p[1000];16 17 int f[1000];18 int n;19 int num;20 21 bool cmp(const dista
阅读全文
posted @
2012-04-16 13:02
Shirlies
阅读(215)
推荐(0)
uva 10048【Audiophobia】
摘要:这一题不错。。。将floyd变了变形。。。代码如下: 1 #include <cstdio> 2 #include <cstring> 3 #include <algorithm> 4 5 int point,street,que; 6 int g[1010][1010]; 7 int cas; 8 9 bool init()10 {11 scanf("%d%d%d",&point,&street,&que);12 if(point == 0&&street == 0&&que ==
阅读全文
posted @
2012-04-16 11:16
Shirlies
阅读(237)
推荐(0)
uva 10034【Freckles】
摘要:Krustral是也。。。View Code 1 #include <cstdio> 2 #include <cstring> 3 #include <algorithm> 4 #include <cmath> 5 6 struct segment 7 { 8 int u,v; 9 double w;10 }s[10000];11 12 struct point13 {14 double x,y;15 }p[110];16 17 int f[105];18 int n;19 int sum;20 double len;21 22 bool cmp
阅读全文
posted @
2012-04-15 23:30
Shirlies
阅读(278)
推荐(0)
uva 567【Risk】
摘要:求最短路,Floyd算法,简单的应用不过题目真的很晦涩。。。第一个数x表示与第i个数(通俗一点,第i行,其实也是标号为i的点)相邻的点的个数,然后后面有x个值。代码如下: 1 #include <cstdio> 2 #include <cstring> 3 #include <algorithm> 4 5 int g[22][22]; 6 int n; 7 8 bool init() 9 {10 int num;11 for(int i = 1;i <= 20;i ++)12 {13 for(int j = 1;j <= 20;j ++)14 .
阅读全文
posted @
2012-04-15 21:27
Shirlies
阅读(266)
推荐(0)