题目链接:

http://www.lydsy.com/JudgeOnline/problem.php?id=1083

代码:

#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std; const int maxn = ;
const int maxm = maxn*maxn; struct Edge {
int u, v, w;
bool operator < (const Edge& tmp) const {
return w < tmp.w;
}
}egs[maxm]; int n, m; int fat[maxn];
int Find(int x) {
return fat[x] = fat[x] == x ? x : Find(fat[x]);
} int main() {
while (scanf("%d%d", &n, &m) == ) {
for (int i = ; i <= n; i++) fat[i] = i;
for (int i = ; i < m; i++) {
scanf("%d%d%d", &egs[i].u, &egs[i].v,&egs[i].w);
}
sort(egs, egs + m);
int ma = -;
for (int i = ; i < m; i++) {
int pu = Find(egs[i].u);
int pv = Find(egs[i].v);
if (pu != pv) {
ma = max(ma, egs[i].w);
fat[pv] = pu;
}
}
printf("%d %d\n", n - , ma);
}
return ;
}

BZOJ 1083: [SCOI2005]繁忙的都市 裸的最小生成树的更多相关文章

  1. BZOJ 1083: [SCOI2005]繁忙的都市【Kruscal最小生成树裸题】

    1083: [SCOI2005]繁忙的都市 Time Limit: 10 Sec  Memory Limit: 162 MBSubmit: 2925  Solved: 1927[Submit][Sta ...

  2. Bzoj 1083: [SCOI2005]繁忙的都市 (最小生成树)

    Bzoj 1083: [SCOI2005]繁忙的都市 题目链接:https://www.lydsy.com/JudgeOnline/problem.php?id=1083 此题是最小瓶颈生成树的裸题. ...

  3. BZOJ 1083: [SCOI2005]繁忙的都市(MST)

    裸的最小生成树..直接跑就行了 ---------------------------------------------------------------------- #include<c ...

  4. BZOJ 1083: [SCOI2005]繁忙的都市 kruskal

    1083: [SCOI2005]繁忙的都市 题目连接: http://www.lydsy.com/JudgeOnline/problem.php?id=1083 Description 城市C是一个非 ...

  5. BZOJ 1083 [SCOI2005]繁忙的都市

    1083: [SCOI2005]繁忙的都市 Time Limit: 10 Sec  Memory Limit: 162 MBSubmit: 1664  Solved: 1080[Submit][Sta ...

  6. BZOJ 1083 [SCOI2005]繁忙的都市 (最小生成树裸题无重边) 超简单写法!!

    Description 城市C是一个非常繁忙的大都市,城市中的道路十分的拥挤,于是市长决定对其中的道路进行改造.城市C的道路是这样分布的:城市中有n个交叉路口,有些交叉路口之间有道路相连,两个交叉路口 ...

  7. bzoj 1083: [SCOI2005]繁忙的都市 (最小生成树)

    链接:https://www.lydsy.com/JudgeOnline/problem.php?id=1083 思路:连接所有点,肯定最少是需要n-1条边的,也就是写个最小生成树,记得保存下最大的权 ...

  8. BZOJ(5) 1083: [SCOI2005]繁忙的都市

    1083: [SCOI2005]繁忙的都市 Time Limit: 10 Sec  Memory Limit: 162 MBSubmit: 4105  Solved: 2595[Submit][Sta ...

  9. 1083: [SCOI2005]繁忙的都市

    1083: [SCOI2005]繁忙的都市 Time Limit: 10 Sec  Memory Limit: 162 MBSubmit: 1319  Solved: 878[Submit][Stat ...

随机推荐

  1. INSERT IGNORE 与 INSERT INTO的区别

    例 insert ignore表示,如果中已经存在相同的记录,则忽略当前新数据: insert ignore into table(name)  select  name from table2 例 ...

  2. [Apache Maven Shade Plugin] [example] [001] 官方例子:includes-excludes

    链接地址:[Selecting Contents for Uber JAR](http://maven.apache.org/plugins/maven-shade-plugin/examples/i ...

  3. iPhone的全球之旅 读书笔记

          最近在看<一只iPhone的全球之旅>,文章主要从iPhone供应链角度入手,从各个方面来详细剖析了iPhone这一智能手机领头羊的生产过程.       苹果iPhone手机 ...

  4. exynos 4412 eMMC配置及使用方法

    /** ****************************************************************************** * @author    Maox ...

  5. VmodCAM 初始化

    ; WIP Last Changed Rev: 2172 ;********************************************************************** ...

  6. ThreadLocal学习记录

    ThreadLocal简介 当使用ThreadLocal维护变量时,ThreadLocal为每个使用该变量的线程提供独立的变量副本,所以每一个线程都可以独立地改变自己的副本,而不会影响其它线程所对应的 ...

  7. 【转】AOP知识点

    ref:http://www.diybloghome.com/prology/975.html 一.概念理解 老规矩,还是先看官方解释:AOP(Aspect-Oriented Programming, ...

  8. VS2005 VS2008编译的程序在Win7下以管理员身份运行的设置

    在VS2005或者VS2008 里面,直接项目右键---属性---连接器---清单文件---uac执行级别   选择requireAdministrator  重新编译 这样你的程序直接运行就拥有管理 ...

  9. 例题6-3 Matrix Chain Multiplication ,Uva 442

    这个题思路没有任何问题,但还是做了近三个小时,其中2个多小时调试 得到的经验有以下几点: 一定学会调试,掌握输出中间量的技巧,加强gdb调试的学习 有时候代码不对,得到的结果却是对的(之后总结以下常见 ...

  10. 使用 Visual Studio Team Test 进行单元测试和java中的测试

    C#中test测试地 方法一. 1.从NUnit官网(http://www.nunit.org/index.php)下载最新版本NUnit,当前版本为NUnit2.5.8. 2.安装后,在VS2008 ...