CF1536E
很强的题。
结论:每个非
证明:记该点值为
- 若
。
考虑该点到
- 若
。
则一定有一个与它相邻的点值为
综上,结论得证。
所以先钦定若干个未知的点为
还有 corner case:
综上,答案即为
code:
点击查看代码
int n,m;
char s[N];
inline int qpow(int x,int y){
int ret=1;
while(y){
if(y&1)
ret=1ll*ret*x%mod;
x=1ll*x*x%mod;
y>>=1;
}
return ret;
}
void Yorushika(){
scanf("%d%d",&n,&m);
int cnt=0;
rep(i,1,n){
scanf("%s",s+1);
rep(j,1,m){
cnt+=s[j]=='#';
}
}
printf("%d\n",qpow(2,cnt)-(cnt==n*m));
}
signed main(){
int t=1;
scanf("%d",&t);
while(t--)
Yorushika();
}