Wa求调
查看原帖
Wa求调
1088800
Eden2027楼主2024/8/19 21:58
#include <bits/stdc++.h>
using namespace std;
#define maxn 2005
int n,l=1,h=1,m,sum=0;
char g[maxn][maxn];
bool vist[maxn][maxn];
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	cin>>n>>m;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)	
			cin>>g[i][j];
	while(1){
		int nh=h,nl=l;
		// cout<<nh<<" "<<nl<<endl;
		for(int i=nh;i<=n;i++){
			bool f=false;char c=g[i][nl];
			for(int j=nl;j<=m;j++){
				if(g[i][j]!=c || m-nl+1<2){
					f=true;
                    // cout<<i<<" "<<j<<" "<<c<<" "<<g[i][j]<<endl;
                }
			}
			if(f==false){
				for(int j=nl;j<=m;j++){
					vist[i][j]=true;
                    // cout<<i<<" "<<j<<endl;
				}
				h=i+1;
			}
		}
		for(int i=nl;i<=m;i++){
			bool f=false;char c=g[nh][i];
			for(int j=nh;j<=n;j++){
				if(g[j][i]!=c || n-nh+1<2){
					f=true;
                }
			}
			if(f==false){
				for(int j=nh;j<=n;j++){
					vist[j][i]=true;
				}
				l=i+1;
			}
		}
        // cout<<endl;
		bool ff=false;
		for(int i=nh;i<=n;i++){
			for(int j=nl;j<=m;j++){
				if(vist[i][j]==true){
					ff=true;
                }
			}
		}
		if(!ff){
			int sum=0;
			for(int i=nh;i<=n;i++){
				for(int j=nl;j<=m;j++)
					sum++;
			}
			cout<<sum;
			return 0;
		}
	}
	return 0;
}
2024/8/19 21:58
加载中...