当前位置:网站首页>[training Day1] spy dispatch
[training Day1] spy dispatch
2022-07-26 17:50:00 【SSL_ GYX】
Spy dispatch

Their thinking
Connect all nodes with the least cost , use Minimum spanning tree .
In order to deal with the cost of participating in the task , We associate each node with “ The root node ” Connected to a , The boundary right is 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;
}
边栏推荐
猜你喜欢

Tensor operation in pytoch

Redisdesktopmanager removes the upgrade prompt

【元宇宙欧米说】剖析 Web3 风险挑战,构筑 Web3 生态安全

我们被一个 kong 的性能 bug 折腾了一个通宵

Spark数据格式UnsafeRow

Sign up now | oar hacker marathon phase III midsummer debut, waiting for you to challenge

第16周OJ实践1 计算该日在本年中是第几天

深度学习实验:Softmax实现手写数字识别

Tree DP problem

Cross Site Request Forgery (CSRF)
随机推荐
线性表的顺序存储结构——顺序表
Gan (generative adversarial network, GaN) generative countermeasure network
[300 opencv routines] 240. Shi Tomas corner detection in opencv
浅谈数据技术人员的成长之路
Tianyi cloud web application firewall (edge cloud version) supports the detection and interception of Apache spark shell command injection vulnerabilities
2019 popularization group summary
Comparison between agile development and Devops
Week 17 free intrusion pointer exercise - output maximum
JS closure simulates private variable interview questions and immediately executes function Iife
Spark unified memory partition
【虚拟机数据恢复】意外断电导致XenServer虚拟机不可用,虚拟磁盘文件丢失的数据恢复案例
COSCon'22城市/学校/机构出品人征集令
Diagram of seven connection modes of MySQL
【欧米读书会】谈谈元宇宙中的创作者经济:无限次元
(24) the top menu of blender source code analysis shows code analysis
Is it safe to open an account online now? Who do you want to open a stock account?
236. 二叉树的最近公共祖先
兆骑科创海外高层次人才引进平台,创业赛事活动路演
# MySQL 七种连接方式图解
kudu设计-tablet