hdu 6122 Color the chessboard
来源:互联网 发布:淘宝如何设置免邮 编辑:程序博客网 时间:2024/04/30 05:13
题目要求所有偶数长宽的子矩阵中0与1个数相同,则所有的
容易发现,若第
那么只需要统计每一列是否可以以
#include<algorithm>#include<iostream>#include<cstring>#include<cstdio>using namespace std;//Container//typedef long long ll;typedef unsigned int ui;#define clr(a)memset(a,0,sizeof(a))const ll md=998244353;ll dp[3000][2];int tx[300],br[3000],n,m;char mt[3010][3010];int _ck(int d,int x){ int i,j,k;for(i=0;i<n;++i,x^=1){ if(mt[i][d]=='?')continue; if(tx[mt[i][d]]!=x)return 0; } return 1;};int __ck(int d,int x){ int i,j,k;for(i=0;i<m;++i,x^=1){ if(mt[d][i]=='?')continue; if(tx[mt[d][i]]!=x)return 0; } return 1;};int ___ck(int x){ int i,j,k;for(i=0;i<m;++i,x^=1){ if(!_ck(i,x))return 0; } return 1;};void cl(){ int i,j,k,d,t;tx['R']=1,tx['B']=0;scanf("%d %d",&n,&m);for(i=0;i<n;scanf("%s",mt[i++])); for(clr(br),i=0;i<m;++i){br[i]+=_ck(i,0);br[i]+=_ck(i,1);} dp[n-1][0]=__ck(n-1,0),dp[n-1][1]=__ck(n-1,1); for(i=n-2;i>=0;--i){ dp[i][0]=(dp[i+1][0]+dp[i+1][1])*__ck(i,0)%md; dp[i][1]=(dp[i+1][0]+dp[i+1][1])*__ck(i,1)%md; } ll rs=1;for(i=0;i<m;++i)rs=rs*br[i]%md; rs=(rs+dp[0][0]+dp[0][1]-___ck(0)-___ck(1)+md)%md; printf("%I64d\n",rs);};int main(){#ifndef ONLINE_JUDGE freopen("in.txt","r",stdin); freopen("out.txt","w",stdout);#endif int t;scanf("%d",&t);while(t--)cl(); return 0;};
阅读全文
0 0
- [HDU 6122] Color the chessboard
- hdu 6122 Color the chessboard
- HDU 6122 Color the chessboard【思维】
- hdu-6122 Color the chessboard 思维
- HDU 6122 Color the chessboard(机智)
- HDU-6122 Color the chessboard(思维题)
- 解题报告:HDU_6122 Color the chessboard (计数)
- Color the ball HDU
- Color the ball HDU
- Color the Ball HDU
- hdu 1556 color the ball
- hdu 1556Color the ball
- HDU 1556 - Color the ball
- hdu 1199 Color the Ball
- HDU 1199-Color the Ball
- Hdu 1556 Color the ball
- hdu 1556 Color the ball
- hdu 1556 Color the ball
- java特性之多态
- 并发编程(1)-概念
- Image Printing Program Based on Halftoning
- 二分查找的递归和非递归
- Springboot 添加fastjson依赖包
- hdu 6122 Color the chessboard
- Android自定义Camera,用SurfaceView预览。
- Linux下开发-realloc
- 【面试】问题整理
- 如何针对浏览器自动保存账号密码,让text自动清空
- 零基础学图形学(6) 几何知识——矩阵是如何工作的:第一部分
- 数据结构学习-指针定义和使用
- 19个PLSQL实例
- NOIP2015 子串 【动态规划】