开始用DFS,交了超时。后来想是不是没有对访问过的节点进行标记,于是开个标记数组。交了,WR。发现没有输出“IMPOSSIBLE”的情况,改完交,又WR。后来换BFS,终于A了,又完成这周的“任务”了。记得上周也是过1009的BFS题,汗!!!

下面附题目:

Power transmission

Time Limit : 10000/5000ms (Java/Other)   Memory Limit : 131072/131072K (Java/Other)
Total Submission(s) : 13   Accepted Submission(s) : 2

Font: Times New Roman | Verdana | Georgia

Font Size: ← →

Problem Description

The project West-East power transmission is famous around the world. It transmits the electricity from western areas to east China. There are many nodes in the power system. Each node is connected with several other nodes in the system by cable. Power can be only transmitted between two connected nodes. For each node, it can’t send power to two or more other nodes at the same time. As we have all known, power will be loss during the transmission. Bob is the chief engineer of the project. He wants to build a transmission line which send power from one node to another node and minimize the power loss at the same time. Now he asks you to help him solve the problem.

Input

There are several test cases. For each test case, the first line contains an integer N (0 < N ≤ 50000) which represents the number of nodes in the power system. Then there will be N groups of data following. For the i-th(0 < i ≤ N) group, the first line is an integer ki (ki ≤ 50), which means the node i is connected with ki nodes. The rest of the i-th group data are divided into ki lines. Each line contains an integer ai (0 < ai ≤ N, ai ≠ i) and an integer bi (0 ≤ bi ≤ 100), which represents power can be transmitted from node i to ai and will loss bi% while transmitting. The last line of input data contains three integers separated by single spaces. The first one is s, the second is t (0 < s, t ≤ N), and the third is the total power M (0 < M ≤ 10^6) at node s.

Output

For each test case, output the minimum of loss power while transmitting from node s to node t. The result should be printed with two digits to the right of the decimal point. If power cannot be transmitted from node s to node t, output “IMPOSSIBLE!” in a line.

Sample Input

4
2
2 50
3 70
2
1 30
4 20
2
1 10
4 40
0
1 4 100

Sample Output

60.00

Hint

In the sample, the best transmission line is 1 -> 2 -> 4, loss power is 100 * 50% + 100 * (100%-50%)*20% = 60.00

Author

TJU

Source

2012 Multi-University Training Contest 2

转载于:https://www.cnblogs.com/Avengers/archive/2013/05/26/3100408.html

2012多校联盟第二场1009 还是BFS相关推荐

  1. 2019杭电多校第二场1009 HDU6599:求本质不同的回文串长度及数量

    hdu6599:求本质不同的回文串长度及数量 hdu6599题意: manacher+后缀自动机+倍增 $O(nlog(n))$ manacher+后缀数组+二分 $O(nlog(n))$ 回文树(回 ...

  2. HDU2019多校第二场 1009(HDU 6599) I Love Palindrome String(回文树(自动机)+manacher)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6599 解题思路: 回文自动机求每个本质不同的子串出现的次数,同时记录每个节点i代表的回文串第一次出现的 ...

  3. 2018牛客暑期ACM多校训练营第二场 - A题

    A题是道水题--结果没注意到编译器不支持I64d卡了快俩小时-- 还要注意的是k=1时不是特例,因为这时候走跟跑还是不一样的-- A  run 输入描述: The first line of inpu ...

  4. 莫队 ---- 值域分块处理优化字典树上的查询 杭电多校2021第二场1004 i love counting

    题目链接 题目大意: 就是给你nnn个数,mmm次询问 每次询问给你l,r,a,bl,r,a,bl,r,a,b问你在[l,r][l,r][l,r]区间里面有多少种种种数c(XOR)a≤bc(XOR)a ...

  5. HDU 5734 Acperience (公式推导) 2016杭电多校联合第二场

    题目:传送门. #include <iostream> #include <algorithm> #include <cstdio> #include <cs ...

  6. 2018牛客网暑期ACM多校训练营第二场 D - money(贪心)

    题目链接 https://www.nowcoder.com/acm/contest/140#question [题目描述] White Cloud is exercising in the playg ...

  7. Swaps and Inversions hdu多校训练第二场 树状数组求逆序数+离散化

    http://acm.hdu.edu.cn/showproblem.php?pid=6318 交换相邻的元素,有几个逆序对,就交换几次使其变成顺序对 #include<bits/stdc++.h ...

  8. 牛客网暑期ACM多校训练营(第二场):J. farm(暴力)

    链接:https://www.nowcoder.com/acm/contest/140/J 来源:牛客网 题目描述 White Rabbit has a rectangular farmland of ...

  9. hdu 多校赛 第二场

    slove  3/12 rank  224 补题   6/12 --------------------------------------------------- hdu 6595 http:// ...

最新文章

  1. org.springframework.beans.factory.BeanCreationException: Error creating bean with name
  2. php如何给进入网页加入密码,怎么给一个PHP密码访问页面加超链接
  3. nagios监控cfg模块
  4. Java8 Stream详解~映射(map/flatMap)
  5. 初识 Vue(01)---(输出 Hello World)
  6. 华为Mate30 Pro高清渲染图曝光:后置四摄+挖孔全面屏
  7. Oracle 扩展sysaux,oracle 清理SYSAUX表空间
  8. 微信群 保存到通讯录
  9. bzoj 1623: [Usaco2008 Open]Cow Cars 奶牛飞车(贪心)
  10. [js]js设计模式-构造函数模式
  11. Windows7 64bit oracle 11g plsql错误 Initialhation orrlr SQK*NET properly installed
  12. python微信图标制作_Python帮你微信头像任意添加装饰,别再@微信官方了!
  13. 规范完整APP开发制作流程
  14. 2023东华大学计算机考研信息汇总
  15. python中数字转英文_如何用Python实现阿拉伯数字转换英文数字 python3 将中文句子中汉字数字转阿拉伯数字...
  16. 1’s Complement和2’s Complement的区别
  17. 奇偶性与魔术(一)——奇偶性的数学本质
  18. vue搭配vux-ui框架
  19. Windows 命令提示符
  20. 通过Xcodeproj深入探究Xcode工程文件 一

热门文章

  1. 长处比短板更容易困住你,读《能力陷阱》有感
  2. CSS/HTML简单静态页面
  3. linux安装mysql centos_Linux CentOS安装Mysql
  4. android音频管理器(AudioManager)
  5. informatica 许可_Informatica安装及使用文档
  6. 初学MSP430F5529时钟以及FLL配置
  7. php动态js导航视频教程,JQ实现动画导航实例代码
  8. Java基本类型转换
  9. 2016OSC源创会年终盛典-前端技术专场-肖光宇
  10. 利普西斯常数_只有西斯绝对