tjut 2870
来源:互联网 发布:linux可以做什么 编辑:程序博客网 时间:2024/06/07 17:32
#include"iostream" #include"cstdio" #include"cstring" using namespace std; const int N=1005; int n,m,ans; char map[N][N],map_t[N][N]; int cnt[N][N],le[N],ri[N]; void solve(char cc,char a,char b,char c) { int i,l,temp; for(i=1;i<=n;i++) for(l=1;l<=m;l++) { if(map[i][l]==a || map[i][l]==b || map[i][l]==c) map_t[i][l]=cc; else map_t[i][l]=map[i][l]; } memset(cnt[0],0,sizeof(cnt[0])); memset(map_t[0],0,sizeof(map_t[0])); for(i=1;i<=n;i++) { cnt[i][0]=cnt[i][m+1]=-1; for(l=1;l<=m;l++) { le[l]=ri[l]=l; if(map_t[i][l]!=cc) cnt[i][l]=0; else cnt[i][l]=cnt[i-1][l]+1; } for(l=2;l<=m;l++) { if(!cnt[i][l]) continue; while(cnt[i][le[l]-1]>=cnt[i][l]) le[l]=le[le[l]-1]; } for(l=m-1;l>0;l--) { if(!cnt[i][l]) continue; while(cnt[i][ri[l]+1]>=cnt[i][l]) ri[l]=ri[ri[l]+1]; } for(l=1;l<=m;l++) { if(!cnt[i][l]) continue; temp=cnt[i][l]*(ri[l]-le[l]+1); if(ans<temp) ans=temp; } } } int main() { int i; while(scanf("%d%d",&n,&m)!=-1) { for(i=1;i<=n;i++) scanf("%s",map[i]+1); ans=0; solve('a','w','y','z'); solve('b','w','x','z'); solve('c','x','y','z'); cout<<ans<<endl; } return 0; }
0 0
- tjut 2870
- tjut 5289
- tjut 5288
- tjut 5294
- tjut 2586
- tjut 5296
- tjut 5297
- tjut 5299
- tjut 5384
- tjut 5387
- tjut 5386
- tjut 5381
- tjut 5400
- tjut 5399
- tjut 5396
- tjut 5398
- tjut 5412
- tjut 5410
- JDBC(四) 数据库连接池
- hdu 5650
- 2016.7.13纪中比赛总结
- FZU 2147 A-B Game(数学推导题)
- HDU 5831 Rikka with Parenthesis II 2016 Multi-University Training Contest 8
- tjut 2870
- 安装sparklyr包过程中遇到的几个ERROR
- HDU-5831-Rikka with Parenthesis II-括号匹配
- hdu 2588 GCD-欧拉函数
- 玩转ButterKnife注入框架
- 基于FPGA的图像比例缩放
- hibernate对分页查询的支持
- 线序
- android多Modle统一配置Gradle