Connect the Cities

Problem Description
In 2100, since the sea level rise, 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
The first line contains the number of test cases.
Each test case starts with three integers: n, m and k. n (3 <= n <=500) stands for the number of survived cities, m (0 <= m <= 25000) stands for the number of roads you can choose to connect the cities and k (0 <= k <= 100) stands for the number of still connected cities.
To make it easy, the cities are signed from 1 to n.
Then follow m lines, each contains three integers p, q and c (0 <= c <= 1000), means it takes c to connect p and q.
Then follow k lines, each line starts with an integer t (2 <= 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
  
  
1 6 4 3 1 4 2 2 6 1 2 3 5 3 4 33 2 1 2 2 1 3 3 4 5 6
 

 

Sample Output
  
  
1
这道题提醒我们!!!
交题要稳重,TLE了好几次!
一定要看清题目的数据量:(3 <= n <=500) (0 <= m <= 25000)
但是最小生成树加进去n-1条边就行!
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
The connect jlink is defective. 连接 jlink 有问题。 这句话意味着 Jlink 连接器存在缺陷或故障。它可能无法正常连接或与其他设备通信。有几种可能的原因可以导致连接 jlink 有问题,比如硬件故障、线路损坏或不良连接等。 要解决这个问题,我们可以采取以下几个步骤: 1. 首先,检查连接 jlink 的线缆是否完好无损。确保线缆的插头和插孔质量良好,并且连接紧密。如果有损坏或松动的情况,可以更换线缆或重新连接来解决问题。 2. 如果线缆没有问题,我们可以检查 Jlink 连接器本身是否存在硬件故障。可以尝试通过连接其他设备来验证连接器是否出现问题。如果确认连接器有故障,可能需要更换一个新的连接器。 3. 除了硬件故障外,也可能是软件设置出现了问题。可以检查使用 Jlink 的软件配置和设置,确保它们与所连接的设备兼容并正确配置。可能需要更新或重新安装软件驱动程序来修复问题。 4. 如果以上步骤都无效,还可以尝试将 Jlink 连接到另一台计算机上进行测试,以排除计算机本身的问题。如果在其他计算机上仍然有连接问题,那么可能需要联系 Jlink 的制造商进行技术支持或更换产品。 总之,当我们遇到连接 jlink 有问题时,我们应该逐步排除硬件和软件方面的故障,并采取适当的措施来修复或替换有缺陷的 Jlink 连接器。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值