当前位置:网站首页>[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;
}
边栏推荐
- leetcode:1206. 设计跳表【跳表板子】
- 如何通过学会提问,成为更加优秀的数据科学家
- 浅谈数据技术人员的成长之路
- Tree DP problem
- Click hijacking attack
- [cloud native] IVX low code development was introduced into Tencent map and previewed online
- Zhaoqi science and technology innovation overseas high-level talent introduction platform, entrepreneurship event Roadshow
- 6-19漏洞利用-nsf获取目标密码文件
- Spark unified memory partition
- 【集训Day1】 Dwarves line up
猜你喜欢

Week 16 OJ practice 1 calculates the day of the year

【欧米读书会】谈谈元宇宙中的创作者经济:无限次元

Tianyi cloud web application firewall (edge cloud version) supports the detection and interception of Apache spark shell command injection vulnerabilities

Hardware development and market industry

浅析接口测试

Come on developer! Not only for the 200000 bonus, try the best "building blocks" for a brainstorming!

(25)Blender源码分析之顶层菜单Blender菜单

Diagram of seven connection modes of MySQL

重磅!《2022中国开源发展蓝皮书》正式发布

ACL实验演示(Huawei路由器设备配置)
随机推荐
Redisdesktopmanager removes the upgrade prompt
Zhaoqi science and technology innovation overseas high-level talent introduction platform, entrepreneurship event Roadshow
[machine learning] principle and code of mean shift
Diagram of seven connection modes of MySQL
Definition of graph traversal and depth first search and breadth first search (I)
Just this time! Talk about the technical solutions of distributed system in detail
第17周自由入侵 指针练习--输出最大值
性能调优bug层出不穷?这3份文档轻松搞定JVM调优
Come on developer! Not only for the 200000 bonus, try the best "building blocks" for a brainstorming
浅谈数据技术人员的成长之路
CCS TM4C123新建工程
SQL injection (mind map)
uni-app
Familiarize you with the "phone book" of cloud network: DNS
图解用户登录验证流程,写得太好了!
Week 16 OJ practice 1 calculates the day of the year
数据库使用psql及jdbc进行远程连接,不定时自动断开的解决办法
JS 函数作用域 变量声明提升 作用域链 不加var的变量,是全局变量
跨站点请求伪造(CSRF)
2.1.2 synchronization always fails