2013年7月26日
摘要: 将边从小到大排序,然后从最小的开始枚举,判断连通,得到当前的速度最小差,比较得出最小值。 1 #include 2 #include 3 #include 4 using namespace std; 5 struct po 6 { 7 int u,v,w; 8 } s[1005]; 9 int p[1005];10 int cmp(po a,po b)11 {12 return a.w<b.w;13 }14 int findSet(int x)15 {16 if (p[x] == x)17 return x;18 return findSet(... 阅读全文
posted @ 2013-07-26 11:48 Ac_国士无双 阅读(228) 评论(0) 推荐(0) 编辑
摘要: 从小到大排序,判断连通。 1 #include 2 #include 3 #include 4 using namespace std; 5 int n,m,u[1000005],v[1000005],w[1000005],r[1000005],p[1005]; 6 int cmp(const int i,const int j) 7 { 8 return w[i]<w[j]; 9 }10 int find (int x)11 {12 if(p[x]==x)13 return x;14 else return p[x]=find(p[x]);15 }16 int... 阅读全文
posted @ 2013-07-26 11:44 Ac_国士无双 阅读(184) 评论(0) 推荐(0) 编辑