#P4030. [Code+#2] 可做题1
[Code+#2] 可做题1
Description
The problem is as follows:
For any -by- matrix, if for any selection of positions with no two in the same row or column, the sum of the values on those positions is always the same, then we call this matrix “clever.” Note that any matrix with is clever. For example, the matrix:
1 2 3
4 5 6
7 8 9
is clever because .
The matrix:
1 2
2 1
is not clever because .
Now you are given an matrix and queries. Each query asks whether a subsquare is clever.
Input Format
Read from standard input.
The first line contains three positive integers .
The next lines each contain space-separated non-negative integers, representing the matrix .
The next lines each contain three positive integers , indicating the -by- square whose top-left corner is at row , column . It is guaranteed that this square lies entirely within .
Output Format
Output to standard output.
Print lines, each containing a single character Y or N. Y means the queried square is clever, and N means it is not.
3 3 4
1 1 1
1 1 1
1 1 2
1 1 2
1 1 3
2 2 2
2 1 2
Y
N
N
Y
Hint

Constraints: For all the testdata, , , .
From CodePlus 2017 December Contest, proudly presented by the Student Association for Algorithms and Programming Contest, Department of Computer Science and Technology, Tsinghua University.
Credit: idea/卢政荣 命题/卢政荣 验题/吕时清,王聿中.
Git Repo: https://git.thusaac.org/publish/CodePlus201712
Thanks to Tencent for supporting this contest.
Translated by ChatGPT 5
京公网安备 11011102002149号