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相关推荐

  1. CF76A·gift

    初见安~[第一次写CF的题解QwQ]这里是传送门:Codeforces 76A Description The kingdom of Olympia consists of N cities and  ...

  2. Flash开发iOS应用全攻略(四)——如何为iTunes Connect准备应用

    在上周我介绍了如何在Flash里发布iOS应用,以及如何申请成为合法的iOS开发者.如何使用iOS开发者授权和申请证书.今天我会给大家介绍一下如果你打算将应用发布到 Apple应用程序商店,都应该做些 ...

  3. Flink入门训练--以New York City Taxi为例

    最近在学Flink,准备用Flink搭建一个实时的推荐系统.找到一个好的网站(也算作是flink创始者的官方网站),上面有关于Flink的上手教程,用来练练手,熟悉熟悉,下文仅仅是我的笔记. 1. 数 ...

  4. 如何为iTunes Connect准备应用

    今天我会给大家介绍一下如果你打算将应用发布到 Apple应用程序商店,都应该做些什么. 如果你已经成功注册了iOS开发者,那么现在就可以登陆iTunes Connect来管理应用程序. 如何申请合同 ...

  5. Meta Connect汇总:Quest Pro发布,主打生产力场景

    一年前,Facebook重磅宣布改名Meta,并宣布元宇宙优先的战略,以及硬件普惠型的策略.这一年经历了不少变化:收购Within被FTC起诉,推出Meta账户,收缩财政支出,Quest 2涨价等等. ...

  6. Scrapy 简易爬取Boss直聘 可设定city job 爬取工作到excel或mysql中

    2018-5-17 一. 本篇讲述了如何编写利用Scrapy爬虫,把数据放入到MYSQL数据库中和写入到excel中,由于笔者之前爬取过拉勾网,但个人倾向与Boss直聘,所以再次爬取Boss直聘来作为 ...

  7. 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. ...

  8. 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 ...

  9. oracle 10035 err 942,案例:Oracle日志报错 Fatal NI connect error 12170 TNS-12535 TNS-00505

    天萃荷净 Oracle数据库alert日志文件报错Fatal NI connect error 12170,通过查看mos相关文章找到解决办法 今天在一台服务器的日志文件中,发现如下信息: Fatal ...

最新文章

  1. Android应用中使用AsyncHttpClient来异步网络数据
  2. zabbix代理服务器搭建
  3. 2019-12-03 有用的学术网站
  4. Eclipse 中切换不同的JDK设置
  5. Effective C++ ------- virtual
  6. Matlab与高等数学
  7. Docker1.8在Centos7下的安装
  8. 一年月份大小月口诀_怀胎十月,为啥我只能算出9个月?
  9. 用Typescript如火如荼地进行angular.js
  10. 折扇的保养方法是什么?
  11. surface simplification using quadratic error metrics
  12. mysql查找配置文件的顺序
  13. 前端开发-技术设计文档编写规范
  14. 【Language model】使用RNN LSTM训练语言模型 写出45°角仰望星空的文章
  15. RMAN维护:RMAN中的交叉校验crosscheck
  16. Google Interview University - 坚持完成这套学习手册,你就可以去 Google 面试了
  17. 【深度学习】时间注意力模块与空间注意力模块
  18. 《信息物理融合系统(CPS)设计、建模与仿真——基于 Ptolemy II 平台》——2.8 小结...
  19. STM32 BMP280模块 获取气压温度高度传感器数据 TFT显示
  20. 【计算机网络——制作双绞线】

热门文章

  1. 【Word及其他文本工具快捷键大全】
  2. 计算机怎样通过交换机接入网络,家用交换机怎么设置?网络交换机连接设置方式步骤...
  3. 面试中的这些问题,你肯定有被问到过,Get
  4. 基于虹软(ArcSoft)实现人脸识别——Android版
  5. PS设计具有现代气息的web站点
  6. 为防止被00后整顿,一公司招聘要求员工不能起诉公司
  7. FPGA笔试题知识点汇总(41~60)
  8. Day30——分组得分最高的所有下标
  9. css中为伪元素增加点击事件和hover
  10. Excel表格里面做省份,市(二级联动效果)