博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Dark roads(kruskal)
阅读量:5239 次
发布时间:2019-06-14

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

Dark roads

Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 32768/32768K (Java/Other)
Total Submission(s) : 7   Accepted Submission(s) : 2
Problem Description
Economic times these days are tough, even in Byteland. To reduce the operating costs, the government of Byteland has decided to optimize the road lighting. Till now every road was illuminated all night long, which costs 1 Bytelandian Dollar per meter and day. To save money, they decided to no longer illuminate every road, but to switch off the road lighting of some streets. To make sure that the inhabitants of Byteland still feel safe, they want to optimize the lighting in such a way, that after darkening some streets at night, there will still be at least one illuminated path from every junction in Byteland to every other junction.
What is the maximum daily amount of money the government of Byteland can save, without making their inhabitants feel unsafe?
 

 

Input
The input file contains several test cases. Each test case starts with two numbers m and n, the number of junctions in Byteland and the number of roads in Byteland, respectively. Input is terminated by m=n=0. Otherwise, 1 ≤ m ≤ 200000 and m-1 ≤ n ≤ 200000. Then follow n integer triples x, y, z specifying that there will be a bidirectional road between x and y with length z meters (0 ≤ x, y < m and x ≠ y). The graph specified by each test case is connected. The total length of all roads in each test case is less than 2[sup]31[/sup].
 

 

Output
For each test case print one line containing the maximum daily amount the government can save.
 

 

Sample Input
7 11 0 1 7 0 3 5 1 2 8 1 3 9 1 4 7 2 4 5 3 4 15 3 5 6 4 5 8 4 6 9 5 6 11 0 0
题解:就把总路径加起来,然后减去最小路径;刚开始用prime包内存;最后用kruscal竟然没超市
代码:
1 #include
2 #include
3 #include
4 using namespace std; 5 const int MAXN=200010; 6 struct Node{ 7 int s,e,dis; 8 }; 9 Node dt[MAXN];10 int cmp(Node a,Node b){11 return a.dis

 

转载于:https://www.cnblogs.com/handsomecui/p/4725631.html

你可能感兴趣的文章
转:基于InfluxDB&Grafana的JMeter实时性能测试数据的监控和展示
查看>>
结对编程博客
查看>>
Kendo MVVM 数据绑定(四) Disabled/Enabled
查看>>
python学习笔记3-列表
查看>>
程序的静态链接,动态链接和装载 (补充)
查看>>
关于本博客说明
查看>>
C++11 生产者消费者
查看>>
IO multiplexing 与 非阻塞网络编程
查看>>
hdu4105  Electric wave
查看>>
基于内容的图片检索CBIR(Content Based Image Retrieval)简介
查看>>
线程androidAndroid ConditionVariable的用法
查看>>
程序电脑VS2008 应用程序配置不正确,未能启动该应用程序。重新安装程序可以修复此问题。解决方法...
查看>>
设置类UIColor使用colorWithRed定义颜色
查看>>
文件语音识别Google语音识别学习札记 - Windows PC机上测试语音识别Strut2教程-java教程...
查看>>
μC/OS-III---I笔记13---中断管理
查看>>
:after,:before,content
查看>>
FTTB FTTC FTTH FTTO FSA
查看>>
OpenAI Gym
查看>>
stap-prep 需要安装那些内核符号
查看>>
网易杭研后台技术中心的博客 -MYSQL :OOM
查看>>