79分求调
查看原帖
79分求调
1356156
Que123456_楼主2024/11/25 20:42

#01和#17WA,最后两个TLE,

#include<iostream>
#include<cstdio>
using namespace std;
const unsigned long long mod=998244353;
bool map[1005][1005]{};int n,m,c,f;
unsigned long long VC=0,VF=0;
void Put(int x,int y){
	if(map[x][y]){return;}
	int Rx=0,Ry=0;
	while(map[x+Rx][y]!=1){Rx++;}Rx--;if(Rx==0){return;}
	while(map[x][y+Ry]!=1){Ry++;}Ry--;if(Ry<2){return;}
	for(int i=y+2;i<=y+Ry;i++){
		int Lx=1;
		while(map[x+Lx][i]!=1){Lx++;}Lx--;
		int RL=Rx*Lx;
		VC+=RL;
		VF+=RL*(y+Ry-i);
	}
	return;
}
int main(){
//	freopen("plant.in","r",stdin);
//	freopen("plant.out","w",stdout);
int t=0,id=0;cin>>t>>id;
while(t--){
	VC=0;VF=0;
	cin>>n>>m>>c>>f;
	for(int i=0;i<=n+1;i++){
	for(int j=0;j<=m+1;j++){
		if(i>n||i<1||j>m||j<1){map[j][i]=1;continue;}
		char p;cin>>p;
		map[j][i]=p-'0';
	}
	}
	for(int i=1;i<=n;i++){
	for(int j=1;j<=m;j++){
		Put(j,i);
		VC%=mod;VF%=mod;
	}
	}
	
	cout<<VC<<' '<<VF<<endl;
	}
//	fclose(stdin);fclose(stdout);
return 0;}
2024/11/25 20:42
加载中...