Bzoj 4824: [Cqoi2017]老C的键盘
来源:互联网 发布:海关出口数据怎么查询 编辑:程序博客网 时间:2024/06/08 15:16
题意简述:给出一个大小为
题解:用
#include<bits/stdc++.h>typedef long long ll;const int N = 105;const int P = 1e9 + 7;struct edge{ int y,next;};edge mp[N];int n,first[N],size[N],s;ll c[N][N],f[N][N],g[N][N],temp[N];char ch[N];void ins(int x, int y){ mp[++s] = (edge) {y,first[x]}; first[x] = s;}void dfs(int cur){ if (cur*2<=n) ins(cur,cur*2); if (cur*2+1<=n) ins(cur,cur*2+1); f[cur][1] = g[cur][1] = size[cur] = 1; for (int t=first[cur]; t>0; t=mp[t].next){ int now = mp[t].y; dfs(now); for (int i=1; i<=size[cur]+size[now]; i++) temp[i] = 0; for (int i=1; i<=size[cur]; i++) for (int j=0; j<=size[now]; j++) if (ch[now] == '>') temp[i+j] += f[cur][i] * g[now][j] % P * c[i-1+j][i-1] % P * c[size[cur]-i+size[now]-j][size[cur]-i] % P; else temp[i+j] += f[cur][i] * (g[now][size[now]] - g[now][j] + P) % P * c[i-1+j][i-1] % P * c[size[cur]-i+size[now]-j][size[cur]-i] % P; for (int i=1; i<=size[cur]+size[now]; i++) f[cur][i] = temp[i] % P, g[cur][i] = (g[cur][i - 1] + f[cur][i]) % P; size[cur] += size[now]; }}int main(){ //freopen("keyboard.in","r",stdin); //freopen("keyboard.out","w",stdout); scanf("%d%s",&n,ch+2); for (int i=0; i<=n; i++) for (int j=0; j<=n; j++) if (j == 0 || j == i) c[i][j] = 1; else c[i][j] = (c[i - 1][j - 1] + c[i - 1][j]) % P; dfs(1); printf("%lld\n",g[1][size[1]]); return 0;}
0 1
- Bzoj 4824: [Cqoi2017]老C的键盘
- [树形DP] BZOJ 4824 [Cqoi2017]老C的键盘
- 4824: [Cqoi2017]老C的键盘
- 【BZOJ4824】 [Cqoi2017]老C的键盘
- [最小割] BZOJ 4823 [Cqoi2017]老C的方块
- BZOJ 4823: [Cqoi2017]老C的方块(最小割)
- 【CQOI2017】老C的方块
- 4822: [Cqoi2017]老C的任务&&bzoj 1935: [Shoi2007]Tree 园丁的烦恼
- 【CQOI2017】bzoj4822 老C的任务
- 【CQOI2017】bzoj4823 老C的方块
- 4822: [Cqoi2017]老C的任务
- 4823: [Cqoi2017]老C的方块
- 【BZOJ4822】 [Cqoi2017]老C的任务
- 【BZOJ4823】 [Cqoi2017]老C的方块
- bzoj4822 cqoi2017 老C的任务【树状数组+扫描】
- bzoj4823 cqoi2017 老C的方块【最大流】
- 4822: [Cqoi2017]老C的任务&&1935: [Shoi2007]Tree 园丁的烦恼
- bzoj4822[CQOI2017]:老C的任务(树状数组/k-dtree)
- 指针删除后一定要将指针赋为0
- form表单
- 逆向销毁单链表中的各个结点
- U-BOOT-2016.07移植 (第三篇) 代码重定位
- Python小练习四——计算器
- Bzoj 4824: [Cqoi2017]老C的键盘
- JS打开摄像头并截图上传
- BZOJ 4800([Ceoi2015]Ice Hockey World Championship-meet in the middle)
- 关于对include包含类声明或定义的文件的一些总结
- Python 中文编码的问题
- Spring 事务管理详解
- leetcode [Count Primes]
- 嵌入式系统上的异步串口通信的实现
- 应用程序初次运行数据库配置小程序(Java版)