Electrification Plan(最小生成树)
摘要:http://acm.sdut.edu.cn:8080/vjudge/contest/view.action?cid=50#problem/D最小生成树模板,注意的是这里有k个发电站,它们不再需要连接其他的发电站,所以任何两个发电站之间的权值是0; 1 #include 2 #include 3 const int maxn = 110; 4 const int INF = 0x3f3f3f3f; 5 int map[maxn][maxn],power[maxn]; 6 int n,k; 7 8 void prim() 9 {10 int dis[maxn],vis[maxn];11...
阅读全文
posted @
2013-11-30 17:29
straw_berry
阅读(246)
推荐(0)
Building a Space Station(kruskal,说好的数论呢)
摘要:Time Limit:1000MSMemory Limit:30000KTotal Submissions:3820Accepted:1950DescriptionYou are a member of the space station engineering team, and are assigned a task in the construction process of the station. You are expected to write a computer program to complete the task.The space station is made up
阅读全文
posted @
2013-10-23 00:03
straw_berry
阅读(370)
推荐(0)
Borg Maze(bfs+prim)
摘要:Time Limit:1000MSMemory Limit:65536KTotal Submissions:6971Accepted:2345DescriptionThe Borg is an immensely powerful race of enhanced humanoids from the delta quadrant of the galaxy. The Borg collective is the term used to describe the group consciousness of the Borg civilization. Each Borg individua
阅读全文
posted @
2013-08-08 16:02
straw_berry
阅读(203)
推荐(0)
最小生成树 最短路
摘要:1 View Code 2 3 int prime(int cur) 4 { 5 int index; 6 int sum = 0; 7 memset(visit, false, sizeof(visit)); 8 visit[cur] = true; 9 for(int i = 0; i graph[index][j]){28 dist[j] = graph[index][j];29 } 30 } 31 } 32 return sum; 3...
阅读全文
posted @
2013-06-21 21:39
straw_berry
阅读(132)
推荐(0)
还是畅通工程 最小生成树 kruskal算法
摘要:某省调查乡村交通状况,得到的统计表中列出了任意两村庄间的距离。省政府“畅通工程”的目标是使全省任何两个村庄间都可以实现公路交通(但不一定有直接的公路相连,只要能间接通过公路可达即可),并要求铺设的公路总长度为最小。请计算最小的公路总长度。Input测试输入包含若干测试用例。每个测试用例的第1行给出村庄数目N ( 2 #include 3 struct node 4 { 5 int st,en,w; 6 }mapp[5000]; 7 int set[5000],n,m; 8 int cmp(struct node x, struct node y) 9 {10 return x...
阅读全文
posted @
2013-05-04 01:39
straw_berry
阅读(162)
推荐(0)
最小生成树 kruskal算法
摘要:1 #include 2 #include 3 struct Edge 4 { 5 int u,v,w; 6 }edge[10010]; 7 int n,m,sett[110]; 8 int cmp(const struct Edge x,const struct Edge y) 9 {10 return x.w < y.w;11 }12 int ffind(int x)13 {14 if(x != sett[x])15 x = ffind(sett[x]);16 return x;17 }18 int kruskal()19 {20 ...
阅读全文
posted @
2013-04-13 21:15
straw_berry
阅读(201)
推荐(0)