题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=3371题目不难 稍微注意一下 要把已经建好的城市之间的花费定义为0,在用普通Prim算法就可以了;我没有用克鲁斯卡尔算法(Kruskal's algorithm),因为这题数据比较大,而且要处理大量的数据...
分类:
其他好文 时间:
2014-08-27 20:30:38
阅读次数:
221
The people of Absurdistan discovered how to build roads only last year. After the discovery, every city decided to build their own road connecting their city with another city. Each newly built road c...
分类:
其他好文 时间:
2014-08-27 10:56:38
阅读次数:
347
Description
A Civil Engineer is given a task to connect n houses with the main electric power station directly or indirectly. The Govt has given him permission to connect exactly n wires to connect...
分类:
其他好文 时间:
2014-08-22 16:24:39
阅读次数:
289
人活着系列之Streetlights
Time Limit: 1000ms Memory limit: 65536K 有疑问?点这里^_^
题目描述
人活着如果是为了家庭,亲情----可以说是在这个世界上最温暖人心的,也是最让人放不下的,也是我在思索这个问题最说服自己接受的答案。对,也许活着是一种责任,为了繁殖下一代,为了孝敬父母,男人要养家糊口,女...
分类:
其他好文 时间:
2014-08-21 09:48:23
阅读次数:
251
我记得 大概是几个月前吧 那时候就看过 次小生成树了 虽然感觉听上去很简单 就是放条边进去 那条边出来 但实现起来不简单那=-=这次 正好做到这题 是次小生成树的 就又去学了下...---传送要是懒得点击链接 我把核心思想写下来. 一种容易想到的方法是枚举删除最小生成树上的边,再求最小生成树。用kr...
分类:
其他好文 时间:
2014-08-20 22:20:33
阅读次数:
483
Network
Time Limit: 1000MS
Memory Limit: 30000K
Total Submissions: 13633
Accepted: 5288
Special Judge
Description
Andrew is working as system administrator and ...
分类:
Web程序 时间:
2014-08-19 19:08:05
阅读次数:
292
Swordfish
Time Limit: 2 Seconds Memory Limit: 65536 KB
There exists a world within our world
A world beneath what we call cyberspace.
A world protected by firewalls,
passwords and the mo...
分类:
其他好文 时间:
2014-08-18 20:32:12
阅读次数:
334
过了样例就能AC
注意一点 0条边特意判断下。是否无法构成生成树也要判断
#include
#include
#include
using namespace std;
#define maxn 110
int parent[maxn];
int N,M;
struct edge
{
int u,v,w;
}edges[maxn*maxn];
int cmp(void const *a,vo...
分类:
其他好文 时间:
2014-08-16 21:08:41
阅读次数:
190
题意:给出n个村庄之间的距离,再给出已经连通起来了的村庄。求把所有的村庄都连通要修路的长度的最小值。思路:Kruskal算法课本代码://Kruskal算法#includeusing namespace std;int fa[120];int get_father(int x){ return fa...
分类:
其他好文 时间:
2014-08-13 14:21:16
阅读次数:
212
题意:。。。
难点:如何判断是不是信息不全:在输入的时候建立并查集,之后判断有几个节点就可以了,剩下的就是kruskal算法。
代码:
#include
#include
#include
#define MAXN 105
#define INF 0x3f3f3f3f
using std::sort;
struct node{
int from;
int to;
int w;
}ed...
分类:
其他好文 时间:
2014-08-12 22:09:14
阅读次数:
257