CF333D.Characteristics of Rectangles
提高+/省选-
通过率:0%
时间限制:3.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Gerald found a table consisting of n rows and m columns. As a prominent expert on rectangular tables, he immediately counted the table's properties, that is, the minimum of the numbers in the corners of the table (minimum of four numbers). However, he did not like the final value — it seemed to be too small. And to make this value larger, he decided to crop the table a little: delete some columns on the left and some on the right, as well as some rows from the top and some from the bottom. Find what the maximum property of the table can be after such cropping. Note that the table should have at least two rows and at least two columns left in the end. The number of cropped rows or columns from each of the four sides can be zero.
杰拉尔德发现了一张由 n 行和 m 列组成的表格。作为一名著名的矩形表格专家,他立即计算出了该表格的“性质值”,即表格四个角上数字的最小值(四个数中的最小值)。然而,他对最终得到的这个值并不满意——它似乎太小了。为了使该值变大,他决定对表格进行适当裁剪:删除左侧若干列、右侧若干列,以及顶部若干行、底部若干行。请找出经过此类裁剪后,表格可能达到的最大性质值。注意:裁剪后表格至少需保留两行和两列。从四个方向(左、右、上、下)各自裁剪的行数或列数可以为零。
输入格式
The first line contains two space-separated integers n and m (2 ≤ n, m ≤ 1000). The following n lines describe the table. The i-th of these lines lists the space-separated integers a__i, 1, a__i, 2, ..., a__i, m (0 ≤ a__i, j ≤ 109) — the m numbers standing in the i-th row of the table.
第一行包含两个以空格分隔的整数 n 和 m(2 ≤ n, m ≤ 1000)。接下来的 n 行描述该表格。其中第 i 行包含 m 个以空格分隔的整数 ai,1,ai,2,...,ai,m(0 ≤ ai,j ≤ 109),表示表格第 i 行中的 m 个数字。
输出格式
Print the answer to the problem.
输出该问题的答案。
输入输出样例
输入#1
2 2 1 2 3 4
输出#1
1
输入#2
3 3 1 0 0 0 1 1 1 0 0
输出#2
0
说明/提示
In the first test case Gerald cannot crop the table — table contains only two rows and only two columns.
In the second test case if we'll crop the table, the table will contain zero in some corner cell. Also initially it contains two zeros in the corner cells, so the answer is 0.
在第一个测试用例中,杰拉尔德无法对表格进行裁剪——该表格仅包含两行和两列。
在第二个测试用例中,如果我们对表格进行裁剪,则表格的某个角上的单元格将包含数字 0。此外,表格初始时已有两个角上的单元格为 0,因此答案为 0。
输入解题思路,AI测评打分。不知道怎么写?