1 条题解
-
0Tethys LV 9 @ 2020-09-13 10:49:36
#include<bits/stdc++.h>
using namespace std;
int n, m, h[2005][2005], s[2005], tot, ans, anss;
int ch[2005][2005];
int main(){
scanf("%d %d", &n, &m);
for(int i = 1; i <= n; i ++){
for(int j = 1; j <= m; j ++){
scanf("%d", &ch[i][j]);
if(i != 1 && ch[i][j] != ch[i - 1][j]){
h[i][j] = h[i - 1][j] + 1;
}else{
h[i][j] = 1;
}
}
}
int j = 1;
for(int i = 1; i <= n; i ++){
j = 1;
while(j <= m){
tot = 0;
s[++ tot] = j - 1;
s[++ tot] = j;
j ++;
while(ch[i][j] != ch[i][j - 1] && j <= m){
while(tot > 1 && h[i][j] < h[i][s[tot]]){
int hig = h[i][s[tot]];
tot --;
int len = j - s[tot] - 1;
ans = max(ans, hig * len);
anss = max(anss, min(len, hig) * min(hig, len));
}
s[++ tot] = j;
j ++;
}
while(tot > 1){
int hig = h[i][s[tot]];
tot --;
int len = j - s[tot] - 1;
ans = max(ans, hig * len);
anss = max(anss, min(len, hig) * min(hig, len));
}
}
}
printf("%d\n%d\n", anss, ans);
return 0;
}
- 1
信息
- 难度
- 9
- 分类
- (无)
- 标签
- 递交数
- 7
- 已通过
- 4
- 通过率
- 57%
- 上传者