FZU 2233 ~APTX4869 贪心+并查集
2024-08-20 04:07:15
分析:http://blog.csdn.net/chenzhenyu123456/article/details/51308460
#include <cstdio>
#include <cstring>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;
typedef long long LL;
typedef pair<int,int>pii;
const int N=8e2+;
const int INF=0x3f3f3f3f;
struct Node{
int u,v,w;
bool operator<(const Node &rhs)const{
return w<rhs.w;
}
}p[N*N];
int tot,n,w,fa[N];
int find(int x){
return x==fa[x]?x:fa[x]=find(fa[x]);
}
int main(){
while(~scanf("%d",&n)){
tot=;
for(int i=;i<=n;++i){
fa[i]=i;
for(int j=;j<=n;++j){
scanf("%d",&w);
if(i<j){++tot,p[tot].u=i,p[tot].v=j,p[tot].w=w;}
}
}
sort(p+,p++tot);
int ans=;
for(int i=;i<=tot;++i){
int u=find(p[i].u),v=find(p[i].v);
if(u!=v){
fa[u]=v;
ans=p[i].w;
}
}
printf("%d\n",ans);
}
return ;
}
最新文章
- 将GridView数据导入到excel,并提供下载
- 学习笔记——Maven pom.xml配置详解
- JS学习笔记(四) 正则表达式(RegExp对象)
- 正整数转换成N进制的数组
- pthread_setcanceltype 线程取消
- WPF - 如何引用external dll中图片
- Coroutine,你究竟干了什么?
- Beijing Perl Workshop - Augest 10th, 2013
- Oracle 免费的数据库
- 运维必备:Oracle自备份精简教程(linux及win)
- R语言-动画
- Mysql变量列表
- 网易面经(Java开发岗)
- Clustering[Introduction]
- React-router4 简单总结
- VIM编码检查
- []map[][]切片map小计
- python使用(二)
- postgresql 指令
- animate动画回调函数
热门文章
- 点击按钮文字变成input框,点击保存变成文字
- php 命名空间(要求php5.3以上)
- 使用jQuery.FileUpload插件和服Backload组件自定义上传文件夹
- animation css3动画与CSS3 @keyframes担配使用创建往复平缓动画
- CentOS 6.4 安装SecurectCRT并破解
- C语言杂记
- ruby的gem和boundle安装解决办法
- int([x[, base]]) : 将一个字符转换为int类型,base表示进制
- hdu 3480
- Linux 串行终端,虚拟终端,伪终端,控制终端,控制台终端的理解