当前位置:网站首页>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
边栏推荐
- 【编译原理】做了一半的LR(0)分析器
- Management background --2 Classification list
- MySQL教程的天花板,收藏好,慢慢看
- Aardio - 封装库时批量处理属性与回调函数的方法
- Seata aggregates at, TCC, Saga and XA transaction modes to create a one-stop distributed transaction solution
- Daily question 1: force deduction: 225: realize stack with queue
- Installation and use of labelimg
- AdaViT——自适应选择计算结构的动态网络
- Memorabilia of domestic database in June 2022 - ink Sky Wheel
- Data storage (1)
猜你喜欢
Data processing skills (7): MATLAB reads the data in the text file TXT with mixed digital strings
Management background --1 Create classification
基于 QEMUv8 搭建 OP-TEE 开发环境
Installation and use of labelimg
Advantages of link local address in IPv6
NetXpert XG2帮您解决“布线安装与维护”难题
网络基础入门理解
关于声子和热输运计算中BORN电荷和non-analytic修正的问题
2022-07-04 the high-performance database engine stonedb of MySQL is compiled and run in centos7.9
Daily question 1: force deduction: 225: realize stack with queue
随机推荐
Daily question 1: force deduction: 225: realize stack with queue
Report on technological progress and development prospects of solid oxide fuel cells in China (2022 Edition)
图像的spatial domain 和 frequency domain 图像压缩
Balanced Multimodal Learning via On-the-fly Gradient Modulation(CVPR2022 oral)
labelimg的安装与使用
MySQL约束的分类、作用及用法
Unity3d minigame-unity-webgl-transform插件转换微信小游戏报错To use dlopen, you need to use Emscripten‘s...问题
3DMAX assign face map
中国1,4-环己烷二甲醇(CHDM)行业调研与投资决策报告(2022版)
[leetcode] 19. Delete the penultimate node of the linked list
void关键字
AI enterprise multi cloud storage architecture practice | Shenzhen potential technology sharing
Applet system update prompt, and force the applet to restart and use the new version
Management background --4, delete classification
Learn the principle of database kernel from Oracle log parsing
extern关键字
柔性数组到底如何使用呢?
第4章:再谈类的加载器
2022-07-05 使用tpcc对stonedb进行子查询测试
pytorch_YOLOX剪枝【附代码】