#P10011. [集训队互测 2023] 网格图最大流计数
[集训队互测 2023] 网格图最大流计数
Problem Description
Given , two positive integer sequences , and a matrix .
Consider a directed graph , where $V=\{S,T\}\cup(\{0,1\}\times ([1,k]\cap\mathbb{Z})^2)$, and consists of three parts:
- $E_1=\{(S,(0,1,a_i)) \mid 1\le i\le n\}\cup\{((1,k,b_i),T)\mid 1\le i\le m\}$
- $E_2=\{((1,i,j),(0,i+1,j))\mid1\le i<k,1\le j\le k\}\cup \{(1,i,j),(0,i,j+1))\mid1\le i\le k,1\le j<k\}$
- $E_3=\{((0,i,j),(1,i,j))\mid 1\le i,j\le k,s_{i,j}=1\}$
Simply put, you can think of each cell , , as being split into an in-node and an out-node . describes the edges between and these nodes, determined by . describes edges from the out-node of each cell to the in-node of the cell above it and the cell to its right. describes edges from the in-node to the out-node within each cell, determined by .
Now treat as a flow network where every edge has capacity . You need to find the maximum flow from source to sink , and the number of maximum flows (two flows are considered different if and only if there exists an edge whose flow value differs between the two flows).
Input Format
The first line contains three positive integers .
The second line contains positive integers .
The third line contains positive integers .
Then follow lines, each a binary string of length , representing the matrix .
Output Format
Output one line with two non-negative integers, representing the maximum flow and the number of maximum flows, respectively. The latter should be taken modulo .
Hint
The sample is provided in the attached file.
For all testdata, .
| Subtask ID | Special Property | Subtask Score | ||
|---|---|---|---|---|
| None | ||||
| and the maximum flow is | ||||
| The maximum flow is | ||||
| None | ||||
Translated by ChatGPT 5