当前位置:网站首页>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
边栏推荐
- 中国固态氧化物燃料电池技术进展与发展前景报告(2022版)
- Aardio - 利用customPlus库+plus构造一个多按钮组件
- UDP编程
- Memorabilia of domestic database in June 2022 - ink Sky Wheel
- 图像的spatial domain 和 frequency domain 图像压缩
- Learn the principle of database kernel from Oracle log parsing
- PVL EDI 项目案例
- 2022-07-04 mysql的高性能数据库引擎stonedb在centos7.9编译及运行
- sizeof关键字
- Netxpert xg2 helps you solve the problem of "Cabling installation and maintenance"
猜你喜欢

2021 geometry deep learning master Michael Bronstein long article analysis

Config:invalid signature solution and troubleshooting details

【数字IC手撕代码】Verilog无毛刺时钟切换电路|题目|原理|设计|仿真

Aardio - 通过变量名将变量值整合到一串文本中

手写ABA遇到的坑

自制J-Flash烧录工具——Qt调用jlinkARM.dll方式
![pytorch_ Yolox pruning [with code]](/img/98/31d6258635ce48ac53819d0ca12d1d.jpg)
pytorch_ Yolox pruning [with code]

ResNet-RS:谷歌领衔调优ResNet,性能全面超越EfficientNet系列 | 2021 arxiv

Chapter 3: detailed explanation of class loading process (class life cycle)

二分图判定
随机推荐
Aardio - 通过变量名将变量值整合到一串文本中
Mise en place d'un environnement de développement OP - tee basé sur qemuv8
(18) LCD1602 experiment
关于声子和热输运计算中BORN电荷和non-analytic修正的问题
Daily question 1: force deduction: 225: realize stack with queue
如何用程序确认当前系统的存储模式?
Pit encountered by handwritten ABA
C# 三种方式实现Socket数据接收
Data storage (1)
2022-07-04 mysql的高性能数据库引擎stonedb在centos7.9编译及运行
UDP编程
Spatial domain and frequency domain image compression of images
【雅思口语】安娜口语学习记录part1
Leetcode exercise - Sword finger offer 26 Substructure of tree
MySQL----初识MySQL
剑指offer刷题记录1
Unity3d minigame-unity-webgl-transform插件转换微信小游戏报错To use dlopen, you need to use Emscripten‘s...问题
[leetcode] 19. Delete the penultimate node of the linked list
树的先序中序后序遍历
AI enterprise multi cloud storage architecture practice | Shenzhen potential technology sharing