【BZOJ1079】[SCOI2008]着色方案【计数DP】【奇怪的姿势】
来源:互联网 发布:ios7cydia软件源 编辑:程序博客网 时间:2024/06/09 15:35
【题目链接】
神奇的题。
【iwtwiioi的题解】
/* Footprints In The Blood Soaked Snow */#include <cstdio>using namespace std;typedef unsigned long long ULL;const int maxn = 16, maxm = 7;const unsigned int p = 1000000007;int n, dp[maxn][maxn][maxn][maxn][maxn][maxm];inline int iread() {int f = 1, x = 0; char ch = getchar();for(; ch < '0' || ch > '9'; ch = getchar()) f = ch == '-' ? -1 : 1;for(; ch >= '0' && ch <= '9'; ch = getchar()) x = x * 10 + ch - '0';return f * x;}inline int dfs(int a, int b, int c, int d, int e, int last) {if(!(a | b | c | d | e)) return 1;if(dp[a][b][c][d][e][last]) return dp[a][b][c][d][e][last];int ans = 0;if(a) ans = (ans + (ULL)(a - (last == 2)) * dfs(a - 1, b, c, d, e, 1) % p) % p;if(b) ans = (ans + (ULL)(b - (last == 3)) * dfs(a + 1, b - 1, c, d, e, 2) % p) % p;if(c) ans = (ans + (ULL)(c - (last == 4)) * dfs(a, b + 1, c - 1, d, e, 3) % p) % p;if(d) ans = (ans + (ULL)(d - (last == 5)) * dfs(a, b, c + 1, d - 1, e, 4) % p) % p;if(e) ans = (ans + (ULL)(e - (last == 6)) * dfs(a, b, c, d + 1, e - 1, 5) % p) % p;return dp[a][b][c][d][e][last] = ans;}int cnt[maxn];int main() {n = iread();for(int i = 1; i <= n; i++) cnt[iread()]++;printf("%d\n", dfs(cnt[1], cnt[2], cnt[3], cnt[4], cnt[5], 0));return 0;}
0 0
- 【BZOJ1079】[SCOI2008]着色方案【计数DP】【奇怪的姿势】
- bzoj1079: [SCOI2008]着色方案 dp
- [BZOJ1079]SCOI2008着色方案|DP
- [BZOJ1079][SCOI2008][DP]着色方案
- [DP] BZOJ1079: [SCOI2008]着色方案
- [bzoj1079][SCOI2008]着色方案
- BZOJ1079: [SCOI2008]着色方案
- bzoj1079 [SCOI2008]着色方案
- bzoj1079 [SCOI2008]着色方案
- bzoj1079: [SCOI2008]着色方案
- bzoj1079[SCOI2008]着色方案
- BZOJ1079[SCOI2008]着色方案
- 【bzoj1079】[SCOI2008]着色方案
- BZOJ1079: [SCOI2008]着色方案
- bzoj1079 [SCOI2008]着色方案
- BZOJ1079 [SCOI2008]着色方案 记忆化搜索DP 妙啊
- 【bzoj1079】【SCOI2008】【着色方案】【记忆化搜索】
- [BZOJ1079][SCOI2008]着色方案(记搜)
- Linux启动流程详解
- java基础知识总结5
- 全文检索——Lucene
- 新团队新系统的奋斗践行
- 笔试题
- 【BZOJ1079】[SCOI2008]着色方案【计数DP】【奇怪的姿势】
- 本地推送
- 《Python数据分析基础教程:Numpy学习指南》- 速记 - 第七章
- 欢迎使用CSDN-markdown编辑器
- Codeforces 658C Bear and Forgotten Tree 3【构造】
- IntentService 与ResultReceiver
- ArduPilotMega (APM) 是市面上最强大的基于惯性导航的开源自驾仪
- Animation 动画介绍和实现
- 录像、录音和拍照