#P14041. [PAIO 2025] Towers
[PAIO 2025] Towers
题目描述
Alice is playing a mobile game where the goal is to protect the base from zombies by placing towers. The base in this game can be represented as a matrix of size . Alice can place towers in any cells that do not go beyond the boundaries of the matrix. The base is considered protected if there is at least one tower in any square. Help Alice find a tower placement that will protect her base. Since she has just started playing and does not have much money, from all possible placements, output the one that has the minimum number of towers.
Implementation Notes
You must implement the following function:
int32 solve(int32 N, int32 M, int32 K)
The inputs have the same meaning as above, and the function must return the answer specified above.
Note that: the function may be called multiple times in a single execution of the program.
提示
Examples
In the following pictures, towers are red circles.
Consider the following call solve(5, 5, 2)
. In this case (), and we create the following arrangement:
::::align{center}
::::
Consider the following call solve(7, 8, 3)
. In this case (), and we create the following arrangement:
::::align{center}
::::
Consider the following call
solve(4, 4, 1)
. In this case (), and we create the following arrangement:
::::align{center}
::::
Sample grader
The sample grader reads , the number of times to call the function solve
, then rows, each containing values of with which to call solve
. It then outputs the output values of solve
on different lines. The input and output files in the examples use this format.
Constraints
- .
- .
- The function is called at most 50 000 times in a single execution.
Scoring
- Subtask 1 (8 points): .
- Subtask 2 (27 points): .
- Subtask 3 (31 points): and divides .
- Subtask 4 (34 points): No additional constraints