Type: Default 1000ms 512MiB

HAOI理想的正方形

You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.

题目描述

原题来自:HAOI 2007

有一个 a×ba\times b 的整数组成的矩阵,现请你从中找出一个 n×nn\times n 的正方形区域,使得该区域所有数中的最大值和最小值的差最小。

输入格式

第一行为三个整数,分别表示 a,b,na,b,n 的值;

第二行至第 a+1a+1 行每行为 bb 个非负整数,表示矩阵中相应位置上的数。

输出格式

输出仅一个整数,为 a×ba\times b 矩阵中所有「n×nn\times n 正方形区域中的最大整数和最小整数的差值」的最小值。

样例

5 4 2
1 2 5 6
0 17 16 0
16 17 2 1
2 10 2 1
1 2 2 2
1

数据范围与提示

对于 20%20\% 的数据 2a,b100,n102\le a,b\le 100,n\le 10
对于 100%100\% 的数据 2a,b1000,na,nb,n1002\le a,b\le 1000,n\le a,n\le b,n\le 100,矩阵中的所有数都不超过 10910^9

4月第四周昆十中教研

Not Claimed
Status
Done
Problem
12
Open Since
2026-5-11 0:00
Deadline
2026-5-28 23:59
Extension
24 hour(s)