设为首页 加入收藏

TOP

POJ 2377 Bad Cowtractors
2014-11-23 21:27:56 来源: 作者: 【 】 浏览:2
Tags:POJ 2377 Bad Cowtractors

这是先前做的几道最小生成树的题目,基本都是裸题。

题意:求最大生成树

由于数据比较水,用prime和krusical都可以。我是用krusical做的



 #include   
#include   
#include   
#include   
#include   
using namespace std;  
int n,m,f[1010];  
struct node  
{  
    int x,y,s;  
}e[20010];  
bool cmp(node s, node v)  
{  
    return s.s>v.s;  
}  
int find(int x)  
{  
    if (x==f[x]) return x;  
    f[x]=find(f[x]);  
    return f[x];  
}  
void krusical()  
{  
    int i,t=0,ans=0;  
    for (i=0; i>n>>m;  
    int i,j;  
    for (i=1; i<=n; i++)  
        f[i]=i;  
    for (i=0; i
#include
#include
#include
#include
using namespace std;
int n,m,f[1010];
struct node
{
    int x,y,s;
}e[20010];
bool cmp(node s, node v)
{
    return s.s>v.s;
}
int find(int x)
{
    if (x==f[x]) return x;
    f[x]=find(f[x]);
    return f[x];
}
void krusical()
{
    int i,t=0,ans=0;
    for (i=0; i>n>>m;
    int i,j;
    for (i=1; i<=n; i++)
        f[i]=i;
    for (i=0; i 
 

】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇数对之差的最大值 下一篇归并排序

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

·如何理解c语言指针和 (2025-12-27 01:19:11)
·为什么C标准库没有链 (2025-12-27 01:19:08)
·玩转C语言和数据结构 (2025-12-27 01:19:05)
·MySQL 基础入门视频 (2025-12-26 23:20:22)
·小白入门:MySQL超详 (2025-12-26 23:20:19)