当前位置:网站首页>【集训Day1】Spy dispatch
【集训Day1】Spy dispatch
2022-07-26 16:55:00 【SSL_GYX】
Spy dispatch

解题思路
用最小的代价将所有节点联系在一起,用最小生成树。
为了处理参加任务的花费,我们将每个节点与 “根节点” 相连,边权为 M k M_k Mk。
code
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
int n,ans,s;
int v[1010];
int minn[1010];
int a[1010][1010];
int main()
{
cin>>n;
for(int i=1;i<=n;i++)
for(int j=1;j<=n;j++)
scanf("%d",&a[i][j]);
for(int i=1;i<=n;i++)
{
int t;
scanf("%d",&t);
minn[i]=t;
a[i][n+1]=a[n+1][i]=t;
}
v[++n]=1;
for(int i=1;i<n;i++)
{
int t,mi=0x3f3f3f3f;
for(int j=1;j<=n;j++)
if(!v[j]&&mi>minn[j])
t=j,mi=minn[j];
v[t]=1;
ans+=mi;
for(int j=1;j<=n;j++)
minn[j]=min(minn[j],a[t][j]);
}
cout<<ans<<endl;
}
边栏推荐
- 得不偿失!博士骗领210万元、硕士骗领3万元人才补贴,全被判刑了!
- Leetcode:1206. design jump table [jump table board]
- 236. 二叉树的最近公共祖先
- Environment setup mongodb
- JS 递归 斐波那契数列 深克隆
- 重磅公布!ICML2022奖项:15篇杰出论文,复旦、厦大、上交大研究入选
- 【云原生之kubernetes实战】安装kubeopertor教程
- Eureka Registry - from entry to application
- 【虚拟机数据恢复】意外断电导致XenServer虚拟机不可用,虚拟磁盘文件丢失的数据恢复案例
- API analysis of Taobao / tmall shipping address list and express delivery fees
猜你喜欢

GAN (Generative Adversarial Network,GAN)生成式对抗网络

国际大咖 VS 本土开源新星 | ApacheCon Asia 主题演讲议程全览

图的遍历的定义以及深度优先搜索和广度优先搜索(一)

图解用户登录验证流程,写得太好了!
![[300 opencv routines] 240. Shi Tomas corner detection in opencv](/img/3a/0b81fb06e91e681ccc928e67297188.png)
[300 opencv routines] 240. Shi Tomas corner detection in opencv

【机器学习】Mean Shift原理及代码

# MySQL 七种连接方式图解

点击劫持攻击

The latest interface of Taobao / tmall keyword search
![Cloud rendering volume cloud [theoretical basis and implementation scheme]](/img/38/0e97d6f015f3cb51e872a8d3ce584a.png)
Cloud rendering volume cloud [theoretical basis and implementation scheme]
随机推荐
(25) top level menu of blender source code analysis blender menu
现在网上开户安全么?股票开户要找谁?
图扑 3D 可视化国风设计 | 科技与文化碰撞炫酷”火花“
On the growth of data technicians
解决哈希冲突的几种方式
Concepts and differences of DQL, DML, DDL and DCL
(24)Blender源码分析之顶层菜单显示代码分析
Is it safe for Huishang futures to open an account online? What is the account opening process?
JS closure simulates private variable interview questions and immediately executes function Iife
COSCon'22城市/学校/机构出品人征集令
leetcode:1206. 设计跳表【跳表板子】
Hardware development and market industry
我们被一个 kong 的性能 bug 折腾了一个通宵
Kudu design tablet
Familiarize you with the "phone book" of cloud network: DNS
In depth exploration of ribbon load balancing
Open source kaggle cat and dog data set -- used in classic CNN classification practice
CCS TM4C123新建工程
Pytest (mind map)
大家下午好,请教一个问题:如何从保存点启动一个之前以SQL提交的作业?问题描述:用SQL在cl