90分!最后一个点超时,求大佬save children
  • 板块P1950 长方形
  • 楼主Geranium
  • 当前回复3
  • 已保存回复3
  • 发布时间2024/7/14 10:34
  • 上次更新2024/7/14 11:52:14
查看原帖
90分!最后一个点超时,求大佬save children
1116622
Geranium楼主2024/7/14 10:34
**#include<bits/stdc++.h>
using namespace std;
const int maxn=3000+10;
int n,m,h[maxn];
long long ans=0;
char a[maxn][maxn]; 
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	scanf("%d%d",&n,&m);
	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++){
		memset(h,0,sizeof(h));
		for(int j=1;j<=m;j++){
			for(int k=i;k<=n;k++){
				if(a[k][j]=='*') break;
				else h[j]++;
			}
		}
		for(int j=1;j<=m;j++){
			int minh=h[j];
			for(int k=j;k<=m;k++){
				if(h[k]==0) break;
				minh=min(minh,h[k]);
				ans+=minh;
			}
		}
	}
	printf("%lld",ans);
	return 0;
}
2024/7/14 10:34
加载中...