Random Maze(福州网络赛)
来源:互联网 发布:java关键词过滤 编辑:程序博客网 时间:2024/05/18 09:16
Random Maze
Time Limit: 10000/3000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 906 Accepted Submission(s): 297
Problem Description
In the game “A Chinese Ghost Story”, there are many random mazes which have some characteristic:
1.There is only one entrance and one exit.
2.All the road in the maze are unidirectional.
3.For the entrance, its out-degree = its in-degree + 1.
4.For the exit, its in-degree = its out-degree + 1.
5.For other node except entrance and exit, its out-degree = its in-degree.
There is an directed graph, your task is removing some edge so that it becomes a random maze. For every edge in the graph, there are two values a and b, if you remove the edge, you should cost b, otherwise cost a.
Now, give you the information of the graph, your task if tell me the minimum cost should pay to make it becomes a random maze.
1.There is only one entrance and one exit.
2.All the road in the maze are unidirectional.
3.For the entrance, its out-degree = its in-degree + 1.
4.For the exit, its in-degree = its out-degree + 1.
5.For other node except entrance and exit, its out-degree = its in-degree.
There is an directed graph, your task is removing some edge so that it becomes a random maze. For every edge in the graph, there are two values a and b, if you remove the edge, you should cost b, otherwise cost a.
Now, give you the information of the graph, your task if tell me the minimum cost should pay to make it becomes a random maze.
Input
The first line of the input file is a single integer T.
The rest of the test file contains T blocks.
For each test case, there is a line with four integers, n, m, s and t, means that there are n nodes and m edges, s is the entrance's index, and t is the exit's index. Then m lines follow, each line consists of four integers, u, v, a and b, means that there is an edge from u to v.
2<=n<=100, 1<=m<=2000, 1<=s, t<=n, s != t. 1<=u, v<=n. 1<=a, b<=100000
The rest of the test file contains T blocks.
For each test case, there is a line with four integers, n, m, s and t, means that there are n nodes and m edges, s is the entrance's index, and t is the exit's index. Then m lines follow, each line consists of four integers, u, v, a and b, means that there is an edge from u to v.
2<=n<=100, 1<=m<=2000, 1<=s, t<=n, s != t. 1<=u, v<=n. 1<=a, b<=100000
Output
For each case, if it is impossible to work out the random maze, just output the word “impossible”, otherwise output the minimum cost.(as shown in the sample output)
Sample Input
22 1 1 22 1 2 35 6 1 41 2 3 12 5 4 55 3 2 33 2 6 72 4 7 63 4 10 5
Sample Output
Case 1: impossibleCase 2: 27
Source
The 36th ACM/ICPC Asia Regional Fuzhou Site —— Online Contest
- Random Maze(福州网络赛)
- HDU4067 Random Maze 最小费用最大流 福州网络赛
- 【网络流】hdu4067 Random Maze
- 【网络流】 HDOJ 4067 Random Maze
- hdu 4068 福州网络赛
- hdu 4067Random Maze(费用流)
- HDU 4067 Random Maze(费用流)
- fzu 1979 福州网络赛I题
- HDU 4066 2011ACM福州网络赛
- 套题总结:2011福州网络赛
- hdu 4070福州网络赛 简单贪心
- hdu 4067 Random Maze
- HDU 4067 Random Maze
- HDU 4067 Random Maze
- Random Maze HDU
- hdu 4067 Random Maze (费用流)(难)
- hdu 4067 Random Maze(最小费用流)
- HDU 4067 Random Maze (最小费用最大流)
- 使用SVD方法实现电影推荐系统
- Java虚拟机内存管理
- jquery中的简单过滤选择器
- poj 1236
- 2003(Floyd)
- Random Maze(福州网络赛)
- oracle行列转换、多行转字符串等总结
- 简易的ATM机
- Dalvik jit分析
- linux0.11是如何加载并执行一个二进制可执行文件和shell脚本文件的?
- POJ 3037 Skiing
- [Android算法] Android 随手指移动的ImageView
- python中获取目录下的文件数
- Linux 卸载