当前位置:网站首页>POJ 1258 Agri-Net
POJ 1258 Agri-Net
2022-07-06 15:10:00 【全栈程序员站长】
大家好,又见面了,我是全栈君。
最小生成树问题。
矩阵输入。
这只是很伤心G++ 服从AC。
C++ 已经RE。
唯一的问题,说的最多的 100 X 100 矩阵啊。
Logically, they are N lines of N space-separated integers. Physically, they are limited in length to 80 characters, so some lines continue onto others.
→_→ 不知各位怎么理解这句。
#include<cstdio>
#include<cstring>
#include<string>
#include<queue>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<iostream>
#include<list>
#include<set>
#include<cmath>
#define INF 0x7fffffff
#define eps 1e-6
using namespace std;
int n;
struct lx
{
int u,v,len;
} l[500*1001];
int fa[1001];
bool cmp(lx a,lx b)
{
return a.len<b.len;
}
int father(int x)
{
if(x!=fa[x])
return fa[x]=father(fa[x]);
}
int main()
{
while(scanf("%d",&n)!=EOF)
{
for(int i=0; i<=n; i++)
fa[i]=i;
int cot=0;
for(int i=1; i<=n; i++)
for(int j=1; j<=n; j++)
{
int len;
scanf("%d",&len);
if(i==j)continue;
l[cot].u=i;
l[cot].v=j;
l[cot++].len=len;
}
sort(l,l+cot,cmp);
int ans=0;
for(int i=0; i<cot; i++)
{
int fu=father(l[i].u);
int fv=father(l[i].v);
if(fu==fv)continue;
fa[fv]=fu;
ans+=l[i].len;
}
printf("%d\n",ans);
}
}版权声明:本文博主原创文章,博客,未经同意不得转载。
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/116986.html原文链接:https://javaforall.cn
边栏推荐
- 中国1,4-环己烷二甲醇(CHDM)行业调研与投资决策报告(2022版)
- Memorabilia of domestic database in June 2022 - ink Sky Wheel
- 机试刷题1
- 2021 geometry deep learning master Michael Bronstein long article analysis
- 2022-07-04 the high-performance database engine stonedb of MySQL is compiled and run in centos7.9
- NetXpert XG2帮您解决“布线安装与维护”难题
- AdaViT——自适应选择计算结构的动态网络
- The ceiling of MySQL tutorial. Collect it and take your time
- 如何实现文字动画效果
- 剑指offer刷题记录1
猜你喜欢

NetXpert XG2帮您解决“布线安装与维护”难题

数据处理技巧(7):MATLAB 读取数字字符串混杂的文本文件txt中的数据

基于 QEMUv8 搭建 OP-TEE 开发环境

(十八)LCD1602实验

Management background --4, delete classification

二分图判定

2022-07-04 the high-performance database engine stonedb of MySQL is compiled and run in centos7.9

Aardio - 利用customPlus库+plus构造一个多按钮组件

Balanced Multimodal Learning via On-the-fly Gradient Modulation(CVPR2022 oral)

Clip +json parsing converts the sound in the video into text
随机推荐
Plafond du tutoriel MySQL, bien collecté, regardez lentement
Leetcode: interview question 17.24 Maximum cumulative sum of submatrix (to be studied)
[Digital IC hand tearing code] Verilog burr free clock switching circuit | topic | principle | design | simulation
Hardware development notes (10): basic process of hardware development, making a USB to RS232 module (9): create ch340g/max232 package library sop-16 and associate principle primitive devices
第4章:再谈类的加载器
Improving Multimodal Accuracy Through Modality Pre-training and Attention
树的先序中序后序遍历
Spatial domain and frequency domain image compression of images
枚举与#define 宏的区别
2022-07-05 stonedb的子查询处理解析耗时分析
(18) LCD1602 experiment
网络基础入门理解
labelimg的安装与使用
NetXpert XG2帮您解决“布线安装与维护”难题
Seata聚合 AT、TCC、SAGA 、 XA事务模式打造一站式的分布式事务解决方案
Aardio - 通过变量名将变量值整合到一串文本中
Config:invalid signature solution and troubleshooting details
【数字IC手撕代码】Verilog无毛刺时钟切换电路|题目|原理|设计|仿真
Export MySQL table data in pure mode
Mise en place d'un environnement de développement OP - tee basé sur qemuv8