【链接】 我是链接,点我呀:)
【题意】

题意

【题解】

dp[i][j][k]表示前i列,有j个联通块下,最后一列的状态为k的方案数
k如果为1的话,表示最后一列两个块不一样,k如果为0表示一样
枚举最后一列的情况转移就好

【代码】

#include <bits/stdc++.h>
using namespace std;
const int maxn=1100;
const long long mod=998244353;
#define ll long long
#define mem(a,b) memset(a,b,sizeof(a))
ll dp[maxn][2*maxn][2],n,m;
int main(){int i,j;mem(dp,0);scanf("%I64d%I64d",&n,&m);dp[1][2][1]=2;dp[1][1][0]=2;for(i=2;i<=n;i++){for(j=1;j<=m;j++){dp[i][j][0]+=2*dp[i-1][j][1]+dp[i-1][j-1][0]+dp[i-1][j][0];dp[i][j][0]%=mod;dp[i][j][1]+=2*dp[i-1][j-1][0]+dp[i-1][j-2][1]+dp[i-1][j][1];dp[i][j][1]%=mod; }}ll ans=(dp[n][m][0]+dp[n][m][1])%mod;printf("%I64d\n",ans);return 0;
}

转载于:https://www.cnblogs.com/AWCXV/p/10702868.html

【Codeforces 1051D】Bicolorings相关推荐

  1. 【CodeForces - 1051D】Bicolorings (dp,类似状压dp)

    题干: You are given a grid, consisting of 22 rows and nn columns. Each cell of this grid should be col ...

  2. 【CodeForces - 144C】Anagram Search(尺取,滑窗问题,处理字符串计数)

    题干: A string t is called an anagram of the string s, if it is possible to rearrange letters in t so ...

  3. 【CodeForces - 574B】Bear and Three Musketeers (枚举边,思维,优秀暴力)

    题干: Do you know a story about the three musketeers? Anyway, you will learn about its origins now. Ri ...

  4. 【CodeForces - 608C】Chain Reaction (二分 或 dp ,思维)

    题干: 题目大意: 题意是在一条直线上坐落着不同位置的灯塔,每一个灯塔有自己的power level,当作是射程范围.现在从最右边的灯塔开始激发,如果左边的灯塔在这个灯塔的范围之内,那么将会被毁灭.否 ...

  5. 「一题多解」【CodeForces 85D】Sum of Medians(线段树 / 分块)

    题目链接 [CodeForces 85D]Sum of Medians 题目大意 实现一个setsetset,支持插入,删除,求∑a5k+3∑a5k+3\sum a_{5k+3}.注意,setsets ...

  6. 【CodeForces 997C】Sky Full of Stars(组合计数)

    题目链接:[CodeForces 997C]Sky Full of Stars 官方题解:Codeforces Round #493 - Editorial 题目大意:有一个n×nn×nn\times ...

  7. 【codeforces 812C】Sagheer and Nubian Market

    [题目链接]:http://codeforces.com/contest/812/problem/C [题意] 给你n个物品; 你可以选购k个物品;则 每个物品有一个基础价值; 然后还有一个附加价值; ...

  8. 【codeforces 508B】Anton and currency you all know

    [题目链接]:http://codeforces.com/contest/508/problem/B [题意] 给你一个奇数; 让你交换一次数字; 使得这个数字变成偶数; 要求偶数要最大; [题解] ...

  9. 【codeforces 711B】Chris and Magic Square

    [题目链接]:http://codeforces.com/contest/711/problem/B [题意] 让你在矩阵中一个空白的地方填上一个正数; 使得这个矩阵两个对角线上的和; 每一行的和,每 ...

  10. 【codeforces 807C】Success Rate

    [题目链接]:http://codeforces.com/contest/807/problem/C [题意] 给你4个数字 x y p q 要求让你求最小的非负整数b; 使得 (x+a)/(y+b) ...

最新文章

  1. python requests 重定向_认识Python最最最常用语重要的库Requests
  2. React:入门计数器
  3. 每日一皮:我当程序员的时候也是...
  4. 【自动驾驶】8. MDC通信架构 + DDS + SOME/IP
  5. SSRS的安装、部署和配置
  6. 云开发是啥?看看它在编程导航项目的实践
  7. 世界坐标系到观察坐标系的变换步骤_带你轻松认识不同坐标系下向量的“变脸”——基变换...
  8. 【GCC】Bug 36793 - x86-64 does not get __sync_synchronize right
  9. linuxweb集群mysql_企业web高可用集群实战之lvs+keepalived+mysql
  10. 初探微信小程序渗透测试
  11. 2021全国大学生电子设计竞赛F题参赛简记
  12. chm格式怎么打开?
  13. 快速排序(过程图解)
  14. 外国人怎样看待Ubuntu麒麟?
  15. C#大恒相机采集图片时图片上下对称折叠了
  16. MSXML2.XMLHTTP
  17. java long 空_long类型判断是否为空
  18. Linux使用GitHub
  19. c语言数据结构-遍历
  20. 5年Java开发月薪43k 谁能想到实习期的我月薪只有2K呢?

热门文章

  1. 1041 Be Unique (20 分) 水题
  2. python(九):函数、匿名函数 lambda
  3. Graph——bfs,dfs
  4. python 智能造句_用python中的markov链造句
  5. html表单提交数据保存到mysql中_php – Canonical:如何将HTML表单数据保存到MySQL数据库中...
  6. 信用评分卡模型分析(基于Python)--理论部分
  7. SLAM--单目尺度漂移(相似变换群Sim3)
  8. SLAM--李群李代数左扰动模型
  9. linux+删除+grub,请问:如何删除grub引导
  10. android65535错误实现,Android 65535问题的解决方法