BZOJ 1083: [SCOI2005]繁忙的都市 裸的最小生成树
题目链接:
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]繁忙的都市 裸的最小生成树的更多相关文章
- BZOJ 1083: [SCOI2005]繁忙的都市【Kruscal最小生成树裸题】
1083: [SCOI2005]繁忙的都市 Time Limit: 10 Sec Memory Limit: 162 MBSubmit: 2925 Solved: 1927[Submit][Sta ...
- Bzoj 1083: [SCOI2005]繁忙的都市 (最小生成树)
Bzoj 1083: [SCOI2005]繁忙的都市 题目链接:https://www.lydsy.com/JudgeOnline/problem.php?id=1083 此题是最小瓶颈生成树的裸题. ...
- BZOJ 1083: [SCOI2005]繁忙的都市(MST)
裸的最小生成树..直接跑就行了 ---------------------------------------------------------------------- #include<c ...
- BZOJ 1083: [SCOI2005]繁忙的都市 kruskal
1083: [SCOI2005]繁忙的都市 题目连接: http://www.lydsy.com/JudgeOnline/problem.php?id=1083 Description 城市C是一个非 ...
- BZOJ 1083 [SCOI2005]繁忙的都市
1083: [SCOI2005]繁忙的都市 Time Limit: 10 Sec Memory Limit: 162 MBSubmit: 1664 Solved: 1080[Submit][Sta ...
- BZOJ 1083 [SCOI2005]繁忙的都市 (最小生成树裸题无重边) 超简单写法!!
Description 城市C是一个非常繁忙的大都市,城市中的道路十分的拥挤,于是市长决定对其中的道路进行改造.城市C的道路是这样分布的:城市中有n个交叉路口,有些交叉路口之间有道路相连,两个交叉路口 ...
- bzoj 1083: [SCOI2005]繁忙的都市 (最小生成树)
链接:https://www.lydsy.com/JudgeOnline/problem.php?id=1083 思路:连接所有点,肯定最少是需要n-1条边的,也就是写个最小生成树,记得保存下最大的权 ...
- BZOJ(5) 1083: [SCOI2005]繁忙的都市
1083: [SCOI2005]繁忙的都市 Time Limit: 10 Sec Memory Limit: 162 MBSubmit: 4105 Solved: 2595[Submit][Sta ...
- 1083: [SCOI2005]繁忙的都市
1083: [SCOI2005]繁忙的都市 Time Limit: 10 Sec Memory Limit: 162 MBSubmit: 1319 Solved: 878[Submit][Stat ...
随机推荐
- jQuery简单邮箱验证
function chekmail() { var szReg = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/; ...
- c#的DateTime.Now函数详解
//2008年4月24日System.DateTime.Now.ToString("D");//2008-4-24System.DateTime.Now.ToString(&quo ...
- 【原创】Oracle函数中对于NO_DATA_FOUND异常处理的研究
一直以来有一个困惑,一直没解决,昨天一哥们问我这个问题,决心弄清楚,终于得到了答案.先看下面这个函数: create or replace function fn_test(c_xm varchar) ...
- 自动化测试平台CATP
CATP:报文类工具,可以测试功能
- KOBEV / KOBED
check the highlighted. the number of execution. if too high, can be the requirement was all met. whi ...
- 网络A、B、C类IP地址的区别
学网络之前得先要明白几个概念:(起初我也不怎么知道后来就慢慢会了) 1字节=8位,1位就是1个数字,所以1字节等于8个数字. 2的8次方,和二进制11111111转换为十进制并不一回事. 0-127是 ...
- 在linux下查看内核版本、gcc版本、操作系统多少位等参数
1. 查看linux版本 cat /etc/issue Ubuntu 11.04 \n \l 2. 查看内核版本 1)cat /proc/version Linux version 2.6.38-13 ...
- 封装cookie
function cookie(name,value,expires){ switch(typeof value){ case 'string': //设置 var exp=''; if(expire ...
- win2008r2 iis7.5 mvc 403.14
痛苦的经历,网上各种办法尝试,不成功 环境如标题:发布403.14 错误 解决办法:很简单,发布时,不要使用预编译(发布期间预编译选项 不能选中) 之后就好了...折磨人的小妖精
- Android 与 Webservice 的快速保存
前面写了一篇android对sqllite的快速保存博客,今天我们来看看android与webservice的交互,相信很多有经验的人自然就想到了soap.但是如果在小型项目中,具有大材小用之嫌.实际 ...