比赛 2025.5.5 评测结果 TTTTTTTTTT
题目名称 cake 最终得分 0
用户昵称 李奇文 运行时间 19.983 s
代码语言 C++ 内存使用 3.08 MiB
提交时间 2025-05-05 09:45:51
显示代码纯文本
#include<bits/stdc++.h>
#define re register
using namespace std;
inline int read(){
	int k=0,f=1;
	char c=getchar();
	for(;!isdigit(c);getchar()) if(c=='-') f=-1;
	for(;isdigit(c);getchar()) k=(k<<1)+(k<<3)+c-'0';
	return k*f;
}
inline void write(int x) {
    if(x<0) putchar('-'),x=-x;
    if(x>9) write(x/10);
    putchar(x%10+'0');
}
int n,sum,m,a[2001][2001],c[2001][2001],vh[2001],vs[2001],ans;
void cakes(int xl,int xr,int y,int w){
	if(y==m+1){
		sum+=w;
		return;
	}
	for(re int i=y;i<=m;++i){
		if((c[xl-1][i-1]-c[xr-1][i-1])==2){
			cakes(xl,xr,i+1,w+1);
		}
	}
	return;
}
void cakeh(int x,int w){
	if(x==n+1){
		ans+=w;
		return;
	}
	for(re int i=x;i<=n;++i){
		if(c[i-1][m]%2==0){
			sum=0;
			cakes(i,x,1,0);
			int hs=sum;
			cakeh(i+1,w*hs);
		}
	}
	return;
}

int main(){
	freopen("cake.in","r",stdin);
	freopen("cake.out","w",stdout);
	n=read();
	m=read();
	for(re int i=1;i<=n;++i){
		for(re int j=1;j<=m;++j){
			char s;
			s=getchar();
			if(s=='Y') a[i][j]=1;
			else a[i][j]=0;
		}
	}
	for(re int i=1;i<=n;++i){
		for(re int j=1;j<=m;++j){
			c[i][j]=c[i][j-1]+c[i-1][j]+a[i][j]-c[i-1][j-1];
		}
	}
	if(c[n][m]%2==1){
		write(0);
		return 0;
	}
	cakeh(1,0);
	write(ans);
    return 0;
}