比赛 |
不准粘代码,必须自己写(HS除外) |
评测结果 |
AAAAAAAAAA |
题目名称 |
棋盘制作 |
最终得分 |
100 |
用户昵称 |
云卷云书 |
运行时间 |
1.764 s |
代码语言 |
C++ |
内存使用 |
74.88 MiB |
提交时间 |
2019-09-25 19:55:47 |
显示代码纯文本
- #include<iostream>
- #include<cstdio>
- using namespace std;
- int x,y,ans1=0,ans2=0,n,m,t,chess[2003][2003],h[2003][2003],l[2003][2003],r[2003][2003];
- int main(){
- freopen("makechess.in","r",stdin);
- freopen("makechess.out","w",stdout);
- cin>>n>>m;
- for(int i=1;i<=n;i++)
- for(int j=1;j<=m;j++){
- scanf("%d",&chess[i][j]);
- }
- for(int i=1;i<=n;i++)
- for(int j=1;j<=m;j++){
- l[i][j]=r[i][j]=j;
- h[i][j]=1;
- }
- for(int i=1;i<=n;i++){
- for(int j=2;j<=m;j++){
- if(chess[i][j]!=chess[i][j-1])
- l[i][j]=l[i][j-1];
- }
- }
- for(int i=1;i<=n;i++){
- for(int j=m-1;j>=1;j--){
- if(chess[i][j]!=chess[i][j+1])
- r[i][j]=r[i][j+1];
- }
- }
- for(int i=1;i<=n;i++){
- for(int j=1;j<=m;j++)
- {
- if(i>1&&chess[i][j]!=chess[i-1][j])
- {
- l[i][j]=max(l[i][j],l[i-1][j]);
- r[i][j]=min(r[i][j],r[i-1][j]);
- h[i][j]=h[i-1][j]+1;
- }
- int x=r[i][j]-l[i][j]+1;
- int y=min(x,h[i][j]);
- ans1=max(ans1,x*h[i][j]);
- ans2=max(ans2,y*y);
- }
- }
- cout<<ans2<<endl<<ans1;
- return 0;
- }