#abc205f. F - Grid and Tokens
F - Grid and Tokens
Score : points
问题陈述
有一个 行和 列的网格。令 表示从上到下第 行、从左到右第 列的方格。
我们有 个棋子。对于第 个棋子,我们可以选择执行以下操作之一:
- 将其放在满足条件 和 的方格 上。
- 不将其放置在网格上。
但是,我们不能将两个棋子放在同一行或同一列中。
最多能在网格上放置多少个棋子?
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
There is a grid with rows and columns. Let denote the square at the -th row from the top and -th column from the left.
We have pieces. For the -th piece, we can choose to do one of the following:
- Put it at a square such that and .
- Do not put it on the grid.
However, we cannot put two pieces in the same row or the same column.
At most how many pieces can we put on the grid?
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the answer.
Sample Input 1
2 3 3
1 1 2 2
1 2 2 3
1 1 1 3
Sample Output 1
2
By putting the first piece at , the second piece at , and not putting the third piece on the grid, we can put two pieces on the grid. We cannot put three, so we should print .
Sample Input 2
5 5 3
1 1 5 5
1 1 4 4
2 2 3 3
Sample Output 2
3
update @ 2024/3/10 09:18:54