Connect city
Description
At the year of 20?? , since some strange reasons, most of the cities disappear.
Though some survived cities are still connected with others, but most of them become disconnected.
The government wants to build some roads to connect all of these cities again,but they don’t want to take too much money.
Input
There are many test cases .
Each test case starts with three integers: N, M and K.
N (2 <= N <= 1000) stands for the number of survived cities, the cities are signed from 1 to N.
M (0 <= m <= 100000) stands for the number of roads you can choose to connect the cities,
K (0 <= K < 10) stands for the number of still connected cities.
Then follow M lines, each contains three integers A, B and C (0 <= C < 1000), means it takes C to connect A and B.
Then follow K lines, each line starts with an integer T (1 <= T <= n) stands for the number of this connected cities.
Then T integers follow stands for the id of these cities.
Output
For each case, output the least money you need to take, if it’s impossible, just output -1.
Sample Input
6 4 3
1 4 2
2 6 1
2 3 5
3 4 33
2 1 2
2 1 3
6 4 5 6 4 5 62 3 2
1 2 2
1 2 22
1 2 222
2 1 2
2 2 1100 3 1
100 100 100
1 2 254
99 98 524
5 1 2 55 88 99
Sample Output
1
0
-1
代码
更多做题心得的详情请查看(记得关注哦)https://mp.weixin.qq.com/s?__biz=MzIyOTM4MDMxNw==&mid=2247483798&idx=1&sn=d4fbd34e50ce4efda39d7710d2dc5dc9&chksm=e842d824df3551320d7f1ed85286b2616aec419f7a852cc5c9c9f270beb237b5e6ca83166162&token=1630951018&lang=zh_CN#rd
Connect city相关推荐
- CF76A·gift
初见安~[第一次写CF的题解QwQ]这里是传送门:Codeforces 76A Description The kingdom of Olympia consists of N cities and ...
- Flash开发iOS应用全攻略(四)——如何为iTunes Connect准备应用
在上周我介绍了如何在Flash里发布iOS应用,以及如何申请成为合法的iOS开发者.如何使用iOS开发者授权和申请证书.今天我会给大家介绍一下如果你打算将应用发布到 Apple应用程序商店,都应该做些 ...
- Flink入门训练--以New York City Taxi为例
最近在学Flink,准备用Flink搭建一个实时的推荐系统.找到一个好的网站(也算作是flink创始者的官方网站),上面有关于Flink的上手教程,用来练练手,熟悉熟悉,下文仅仅是我的笔记. 1. 数 ...
- 如何为iTunes Connect准备应用
今天我会给大家介绍一下如果你打算将应用发布到 Apple应用程序商店,都应该做些什么. 如果你已经成功注册了iOS开发者,那么现在就可以登陆iTunes Connect来管理应用程序. 如何申请合同 ...
- Meta Connect汇总:Quest Pro发布,主打生产力场景
一年前,Facebook重磅宣布改名Meta,并宣布元宇宙优先的战略,以及硬件普惠型的策略.这一年经历了不少变化:收购Within被FTC起诉,推出Meta账户,收缩财政支出,Quest 2涨价等等. ...
- Scrapy 简易爬取Boss直聘 可设定city job 爬取工作到excel或mysql中
2018-5-17 一. 本篇讲述了如何编写利用Scrapy爬虫,把数据放入到MYSQL数据库中和写入到excel中,由于笔者之前爬取过拉勾网,但个人倾向与Boss直聘,所以再次爬取Boss直聘来作为 ...
- Docker使用遇到问题Got permission denied while trying to connect to the Docker daemon socket解决方案
Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker. ...
- Can 't connect to local MySQL server through socket '/tmp/mysql.sock '(2)
安装了mysql, 使用命令mysql -u root -p 弹出Can 't connect to local MySQL server through socket '/tmp/mysql.soc ...
- oracle 10035 err 942,案例:Oracle日志报错 Fatal NI connect error 12170 TNS-12535 TNS-00505
天萃荷净 Oracle数据库alert日志文件报错Fatal NI connect error 12170,通过查看mos相关文章找到解决办法 今天在一台服务器的日志文件中,发现如下信息: Fatal ...
最新文章
- Android应用中使用AsyncHttpClient来异步网络数据
- zabbix代理服务器搭建
- 2019-12-03 有用的学术网站
- Eclipse 中切换不同的JDK设置
- Effective C++ ------- virtual
- Matlab与高等数学
- Docker1.8在Centos7下的安装
- 一年月份大小月口诀_怀胎十月,为啥我只能算出9个月?
- 用Typescript如火如荼地进行angular.js
- 折扇的保养方法是什么?
- surface simplification using quadratic error metrics
- mysql查找配置文件的顺序
- 前端开发-技术设计文档编写规范
- 【Language model】使用RNN LSTM训练语言模型 写出45°角仰望星空的文章
- RMAN维护:RMAN中的交叉校验crosscheck
- Google Interview University - 坚持完成这套学习手册,你就可以去 Google 面试了
- 【深度学习】时间注意力模块与空间注意力模块
- 《信息物理融合系统(CPS)设计、建模与仿真——基于 Ptolemy II 平台》——2.8 小结...
- STM32 BMP280模块 获取气压温度高度传感器数据 TFT显示
- 【计算机网络——制作双绞线】