[Solution] Grass Field Codeforces Solution | Solution CodeForces
There is a field of size . Each cell of this field can either contain grass or be empty. The value is if the cell contains grass, or otherwise.
In one move, you can choose one row and one column and cut all the grass in this row and this column. In other words, you choose the row and the column , then you cut the grass in all cells and all cells for all from to . After you cut the grass from a cell, it becomes empty (i. e. its value is replaced by ).
Your task is to find the minimum number of moves required to cut the grass in all non-empty cells of the field (i. e. make all zeros).
You have to answer independent test cases.
The first line of the input contains one integer () — the number of test cases. Then test cases follow.
Grass Field Codeforces Solution
Permutation Codeforces Solution
Schedule Management Codeforces Solution
Permutation Restoration Codeforces Solution
Text Editor Codeforces Solution
The test case consists of two lines, each of these lines contains two integers. The -th integer in the -th row is . If then the cell is empty, and if the cell contains grass.
For each test case, print one integer — the minimum number of moves required to cut the grass in all non-empty cells of the field (i. e. make all zeros) in the corresponding test case.
No comments:
Post a Comment