#P13345. [EGOI 2025] IMO

    ID: 15211 远端评测题 6000ms 1024MiB 尝试: 0 已通过: 0 难度: 6 上传者: 标签>动态规划 DP2025EGOI(欧洲/女生)

[EGOI 2025] IMO

题目描述

The International Mathematics Olympiad (IMO) is a maths competition for high school students that is held every year. The 2025 edition of the IMO takes place at the same time as the EGOI. As you are reading this, both contest days of the IMO have ended and the grading is probably almost done as well. Unlike programming competitions like the EGOI, the grading is done by hand, which is a long and arduous process.

This year the IMO had MM problems (numbered from 00 to M1M - 1), and each problem is worth a maximum of KK points. There were NN contestants taking part in the contest. The iith contestant received a score of ai,ja_{i,j} on problem jj, where ai,ja_{i,j} is an integer between 00 and KK, inclusive. The ranking of the contestants is determined by the total score of each contestant, with ties broken by the contestants' indices. More formally, contestant xx ranks higher than contestant yy if:

  • either the total score of contestant xx is bigger than the total score of contestant yy,
  • or their total scores are the same and x<yx < y.

In order to release the final ranking, the organizers need to publish some of the values ai,ja_{i,j}. If a value is unpublished, it is only known that it is an integer between 00 and KK, inclusive.

The organizers want to reveal as few of the values ai,ja_{i,j} as possible. At the same time, they need to make sure that everyone knows the correct final ranking. In other words, they must reveal a set of values such that the only ranking consistent with it is the correct one.

Find the smallest SS such that it is possible to reveal SS of the values ai,ja_{i,j} in a way that uniquely determines the full ranking of the contestants.

输入格式

The first line contains three integers NN, MM, and KK: the number of contestants, the number of problems, and the maximum score of the tasks, respectively.

Then follow NN lines, where the iith line contains ai,ja_{i,j}. That is, the first of these contains a0,0,a0,1,,a0,M1a_{0,0}, a_{0,1}, \ldots, a_{0,M-1}, the second contains a1,0,a1,1,,a1,M1a_{1,0}, a_{1,1}, \ldots, a_{1,M-1}, and so on.

输出格式

Print one integer SS, the minimum number of scores that can be revealed so that the final ranking is uniquely determined.

4 6 7
7 7 0 2 7 0
7 3 0 7 2 1
7 0 0 7 0 0
7 7 7 7 7 1
20
2 1 1
1
0
1
2 2 7
7 4
7 0
2
2 2 1
0 1
1 0
2

提示

Examples

In the first example, the 20 scores can be revealed in the following way:

7 0 \cdot 7 \cdot
7 3 0 7 2 1
\cdot 0 \cdot 0
7 1

Here, the third contestant is known to have a total score between 0 and 14, which is definitely lower than any other score. It can be shown that it is impossible to reveal fewer than 20 scores. For example, if we were to hide one of the zeroes of the third contestant, then this contestant could have a total score of up to 21. This is a problem because the second contestant has a total score of 20, but should be guaranteed to rank higher than the third contestant.

The first sample satisfies the constraints of test groups 5 and 6.

In the second example, we can either reveal only the first contestant's only score, or reveal only the second contestant's only score (but not both). If we reveal only the first contestant's score, then we know that the first contestant has a total score of 1. This means that even if the second contestant also has a score of 1, the first contestant will rank higher because their index is lower. Similarly, if we only reveal the score of the second contestant, we know that they have a score of zero, which means that the first contestant will rank higher regardless of their score.

The second sample satisfies the constraints of test groups 2, 3, 4, 5, and 6.

The third sample satisfies the constraints of test groups 2, 3, 5, and 6.

The fourth sample satisfies the constraints of all test groups.

Constraints and scoring

  • 2N200002 \leq N \leq 20000.
  • 1M1001 \leq M \leq 100.
  • 1K1001 \leq K \leq 100.
  • 0ai,jK0 \leq a_{i, j} \leq K for every pair i,ji, j where 0iN10 \leq i \leq N - 1 and 0jM10 \leq j \leq M - 1.

Your solution will be tested on a set of test groups, each worth a number of points. Each test group contains a set of test cases. To get the points for a test group, you need to solve all test cases in the test group.

Group Score Limits
1 10 N=M=2N = M = 2 and K=1K = 1
2 13 N=2N = 2
3 10 NM16N \cdot M \leq 16
4 18 K=1K = 1
5 21 N10000N \leq 10000 and M,K10M, K \leq 10
6 28 No additional constraints