Sicily 1696/1929. Flows in Grid
来源:互联网 发布:网络作家排行 编辑:程序博客网 时间:2024/04/29 10:07
1696. Flows in Grid
Constraints
Time Limit: 1 secs, Memory Limit: 32 MB
Description
The maximum flow problem in general graph is so hard that bob doesn’t know how to solve it. So bob want to try an easy one, the maximum flow in grid. But this easier one is still too hard for bob. Now here is his problem, please help him:
Given you a N*M grid as followed, edges of the grid represent pipes which the water can run through; the number of the edge is the capacity of the pipe. For example the capacity of the edge between (0,0) and (1,0) is 6, it means that at most 6 units of water can run through this edge(pipe).
So what is the maximum flow from S to T in the grid? In other words, at most how many units of water can run through from S to T at a time?
Input
The first line of the input is a positive integer T. T is the number of the test cases followed.
The first line of each test case is two positive integers N(1<N<100) and M(1<M<100). And then two integer matrices H( N*(M-1) ) and V ( (N-1)*M )follow. H[i][j] is the capacity of the edge between (i, j) and (i, j+1). V[i][j] is the capacity of the edge between (i, j) and (i+1, j). All integers in H and V are non-negative and smaller than 10^10.
Output
The output of each test case is an integer in one line, the maximum flow of the grid between S(0,0) and T(N-1,M-1). No redundant spaces are needed.
Sample Input
13 30 12 34 56 7 89 10 11
Sample Output
6
Hint
Here is one of the maximum flows of the example grid above:
- Sicily 1696/1929. Flows in Grid
- Sicily 1696 Flows in Grid(最大流)
- Exception in AppMerge flows' progression
- Sicily 1736. Electric Power Grid
- Regarding modified drag force formulation for application in dense flows
- CDH的Flume配置Adding multiple flows in an agent
- Sicily 1527. Tiling a Grid With Dominoes
- sicily 1527. Tiling a Grid With Dominoes
- Sicily 1527. Tiling a Grid With Dominoes
- sicily Tiling a Grid With Dominoes
- <Sicily>Tiling a Grid With Dominoes
- Print() in grid
- Data Grid in Zend
- WebLogic报错Unable to access the selected application. Exception in AppMerge flows' progression
- weblogic12.1.1.0部署项目时报Exception in AppMerge flows' progression错误
- Using Property Grid in C#
- extjs-conditianal combobox in grid
- Best Route in a Grid
- 大一下学期理想规划
- Ubuntu上Android官方开发网站教程(developer.android.com)
- [NOIP 2012] 借教室 · 线段树
- 前端笔试题笔记(回到顶部组件)
- Android_JSON解析
- Sicily 1696/1929. Flows in Grid
- 13 layers hardwood core dynea brown film faced plywood
- 14,Longest Common Prefix
- 适配器的作用和原理
- Sicily 1195. Summation
- 单片机计算需要注意的问题
- 迷宫的最短路路径
- linux下文件显示和乱码
- LeetCode OJ Binary Search Tree Iterator