博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Intelligence System
阅读量:6819 次
发布时间:2019-06-26

本文共 3364 字,大约阅读时间需要 11 分钟。

Intelligence System

Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 57 Accepted Submission(s): 27
 
Problem Description
After a day, ALPCs finally complete their ultimate intelligence system, the purpose of it is of course for ACM ... ...
Now, kzc_tc, the head of the Intelligence Department (his code is once 48, but now 0), is sudden obtaining important information from one Intelligence personnel. That relates to the strategic direction and future development of the situation of ALPC. So it need for emergency notification to all Intelligence personnel, he decides to use the intelligence system (kzc_tc inform one, and the one inform other one or more, and so on. Finally the information is known to all).
We know this is a dangerous work. Each transmission of the information can only be made through a fixed approach, from a fixed person to another fixed, and cannot be exchanged, but between two persons may have more than one way for transferring. Each act of the transmission cost Ci (1 <= Ci <= 100000), the total cost of the transmission if inform some ones in our ALPC intelligence agency is their costs sum.
Something good, if two people can inform each other, directly or indirectly through someone else, then they belong to the same branch (kzc_tc is in one branch, too!). This case, it’s very easy to inform each other, so that the cost between persons in the same branch will be ignored. The number of branch in intelligence agency is no more than one hundred.
As a result of the current tensions of ALPC’s funds, kzc_tc now has all relationships in his Intelligence system, and he want to write a program to achieve the minimum cost to ensure that everyone knows this intelligence.
It's really annoying!
 
Input
There are several test cases.
In each case, the first line is an Integer N (0< N <= 50000), the number of the intelligence personnel including kzc_tc. Their code is numbered from 0 to N-1. And then M (0<= M <= 100000), the number of the transmission approach.
The next M lines, each line contains three integers, X, Y and C means person X transfer information to person Y cost C.
 
Output
The minimum total cost for inform everyone.
Believe kzc_tc’s working! There always is a way for him to communicate with all other intelligence personnel.
 
Sample Input
3 30 1 1001 2 500 2 1003 30 1 1001 2 502 1 1002 20 1 500 1 100
 
Sample Output
15010050
 
 
Source
2009 Multi-University Training Contest 17 - Host by NUDT
 
Recommend
lcy
 
/*题意:给出n个人能联系的关系,和相应的电话费,让你求出最少的电话费初步思路:强连通,缩点*/#include
using namespace std;const int InF=1e9+7;const int maxn=50005;const int maxm=100005;int n,m,cnt,id;/**************************强连通模板******************************/int dfn[maxn],low[maxn],cost[maxn],in[maxn];vector
G[maxn];stack
s;bool inq[maxn];struct edge{ int u,v,w; edge(int u=0,int v=0,int w=0):u(u),v(v),w(w){}}E[maxm];void init(){ cnt=id=0; while(!s.empty()) s.pop(); memset(dfn,0,sizeof dfn); memset(low,0,sizeof low); memset(in,0,sizeof in); for(int i=0;i<=n;i++){ cost[i]=InF; G[i].clear(); inq[i]=false; }}void Tarjan(int x){ dfn[x]=low[x]=++id; inq[x]=true; s.push(x); int t,Size=G[x].size(); for(int i=0;i

 

转载于:https://www.cnblogs.com/wuwangchuxin0924/p/6425958.html

你可能感兴趣的文章
Less学习
查看>>
一个在线的C++帮助文档网站 转载
查看>>
软件架构的5种视图
查看>>
jQuery相关知识总结
查看>>
瑞星:“007小游戏论坛”、“2144小游戏”等网站被挂马
查看>>
用情境搜索开启未来之路,互联网营销
查看>>
一起谈.NET技术,在ASP.NET中自动合并小图片并使用CSS Sprite显示出来
查看>>
VMwave Workstation 12 PRO 下安装黑苹果OS X 10.11.1教程
查看>>
eval & exec(绕过长度限制思路学习)
查看>>
python学习资料
查看>>
JQuery与js具体使用的区别(不全,初学)
查看>>
Hyper-V快速导入虚拟机的两个注意事项
查看>>
【转】getopt模块,实现获取命令行参数
查看>>
安装JDK和配置环境变量
查看>>
behavior planning——10 behaior planning pseudocode
查看>>
C# 正则表达式大全
查看>>
jquery获取radio选中的值或者select做出判断事件
查看>>
STL——queue
查看>>
说一下函数重载和覆盖的区别
查看>>
C++关键字--volatile
查看>>