logo AlgoBeat OnlineJudge
登录 注册

#214173. [PAIO 2025] Towers

内存限制:2048 MiB 时间限制:1000 ms 标准输入输出
题目类型:VJudge(洛谷) 评测方式:VJudge
上传者: 匿名

题目描述

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

  1. Subtask 1 (8 points): .
  2. Subtask 2 (27 points): .
  3. Subtask 3 (31 points): and divides .
  4. Subtask 4 (34 points): No additional constraints