#P3231. [HNOI2013] 消毒
[HNOI2013] 消毒
Description
Xiao T has run into big trouble while working in a biology lab. Due to a recent upgrade, his compartmentalized dish is a rectangular box with dimensions . For convenience, it is partitioned into unit cubes, each of size , and a unit cube is denoted by . The dish has not been used for a long time. Now, Xiao T is required by his advisor to disinfect some of the unit cubes (each unit cube may be disinfected multiple times).
Due to strict experimental requirements, he must use a specific reagent F. This reagent F is peculiar: each time he disinfects a rectangular box of size (consisting of unit cubes), it costs only units of reagent F. Since reagent F is expensive, Xiao T wants to minimize the total amount used.
Please tell him the minimum total units of reagent F required.
Input Format
This problem contains multiple testcases.
- The first line contains a positive integer , the number of testcases.
- For each testcase, the first line contains three positive integers , the dimensions of the dish.
- Then follow blocks. For each , read a -row, -column
01matrix with entries separated by spaces.0means the corresponding unit cube does not need disinfection, and1means it needs disinfection. For example, if the entry of the first01matrix is1, then unit cube must be disinfected.
Output Format
Output lines. For each testcase, output one integer: the minimum total units of reagent F required.
1
4 4 4
1 0 1 1
0 0 1 1
0 0 0 0
0 0 0 0
0 0 1 1
1 0 1 1
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
1 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
1 0 0 0
3
Hint
Sample 1 explanation: Disinfecting regions and costs units and unit of reagent F, respectively.
Constraints: For of the testdata, it is guaranteed that , , and .
Translated by ChatGPT 5
京公网安备 11011102002149号