比赛 |
EYOI与SBOI开学欢乐赛11th |
评测结果 |
AATTTTTTTT |
题目名称 |
矩形地块(A Strip of Land) |
最终得分 |
20 |
用户昵称 |
HeSn |
运行时间 |
24.462 s |
代码语言 |
C++ |
内存使用 |
12.17 MiB |
提交时间 |
2022-10-14 19:23:01 |
显示代码纯文本
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int MAXN = 1010;
int n, m, c, a[MAXN][MAXN], ans;
signed main() {
freopen("land.in", "r", stdin);
freopen("land.out", "w", stdout);
cin >> m >> n >> c;
for(int i = 1; i <= n; i ++) {
for(int j = 1; j <= m; j ++) {
cin >> a[i][j];
}
}
for(int i = 1; i <= n; i ++) {
for(int j = 1; j <= m; j ++) {
int flg = 1;
for(int k = i; k <= n; k ++) {
for(int l = j; l - j + 1 <= 100, l <= m; l ++) {
int maxn = -1e9, minn = 1e9;
flg = 1;
for(int i1 = i; i1 <= k; i1 ++) {
for(int j1 = j; j1 <= l; j1 ++) {
maxn = max(maxn, a[i1][j1]);
minn = min(minn, a[i1][j1]);
if(maxn - minn > c) {
flg = 0;
break;
}
}
if(!flg) {
break;
}
}
if(flg) {
int x = (k - i + 1) * (l - j + 1);
if(x > ans) {
// cout << i << ' ' << j << ' ' << k << ' ' << l << endl;
}
ans = max(ans, x);
}
else {
break;
}
}
}
}
}
cout << ans;
return 0;
}