#P2216. [HAOI2007] 理想的正方形
[HAOI2007] 理想的正方形
Description
Given an matrix of integers, find an square region such that the difference between the maximum and minimum numbers in that region is minimized.
Input Format
The first line contains 3 integers, representing the values of , , and .
From the second line to the -th line, each line contains nonnegative integers, representing the numbers at the corresponding positions in the matrix. Adjacent numbers on the same line are separated by a single space.
Output Format
Output a single integer: the minimal possible difference between the maximum and the minimum among all square regions in the matrix.
5 4 2
1 2 5 6
0 17 16 0
16 17 2 1
2 10 2 1
1 2 2 2
1
Hint
All numbers in the matrix do not exceed 1,000,000,000.
Constraints:
For 20% of the testdata, , , , .
For 100% of the testdata, , , , .
Translated by ChatGPT 5
京公网安备 11011102002149号