4606: [Apio2008]DNA
4606: [Apio2008]DNA
Time Limit: 10 Sec Memory Limit: 128 MB
Submit: 63 Solved: 36
[Submit][Status][Discuss]
Description
Input
Output
Sample Input
ACANNCNNG
Sample Output
HINT
Source
题意:
给定一个长度为m的由ACGTN组成的字符串,定义大小关系A<C<G<T,你要把其中的N替换成ACGT的其中一个,满足最多有k个不下降的子序列的同时,求出第R大的字符串。
M⩽50000 R⩽1012 K⩽10
题解:
明显的计数类DP
用f[i][j][k]表示第i到n位第i位是j,这部分分了k段的个数.
这个容易转移,然后我们就一步步走呗。
f[i][j][k]=∑(f[i+1,l,k或k-1]){k或k-1视j与l的关系而定,如果j>l则为k-1,否则为k}。
复杂度 O(16MK)
#include<cstdio>
using namespace std;
typedef long long ll;
const int N=5e4+;
int n,m,a[N];ll now;
ll f[N][][];
ll s[N][][];
char str[N],path[]={,'A','C','G','T'};
int main(){
scanf("%d%d%lld",&n,&m,&now);//M K R
scanf("%s",str+);
for(int i=;i<=n;i++){
if(str[i]!='N'){
a[i]=str[i]=='A'?:
str[i]=='C'?:
str[i]=='G'?:;
}
}
if(a[n]) f[n][a[n]][]=;
else for(int i=;i<=;i++) f[n][i][]=;
for(int i=n-;i;i--){
for(int j=;j<=;j++){
if(!a[i]||a[i]==j){
for(int k=;k<=m;k++){
for(int l=;l<=;l++){
f[i][j][k]+=f[i+][l][k-(l<j)];
}
}
}
}
}
for(int i=;i<=n;i++){
for(int j=;j<=;j++){
for(int k=;k<=m;k++){
s[i][j][k]=s[i][j][k-]+f[i][j][k];
}
}
}
for(int i=,j,k=;i<=n;i++){
if(a[i]){
putchar(path[a[i]]);
if(k>a[i]) m--;
k=a[i];
}
else{
for(j=;j<=&&s[i][j][m-(k>j)]<now;j++) now-=s[i][j][m-(k>j)];
putchar(path[j]);
if(k>j) m--;
k=j;
}
}
return ;
}
4606: [Apio2008]DNA的更多相关文章
- bzoj 4606: [Apio2008]DNA【dp】
写题五分钟读题两小时系列-- 看懂题的话不算难,然而我去看了大佬的blog才看懂题-- 题目大意是:一个原字符串,其中有一种通配符,合法串的定义是这个串(不含通配符))可以匹配原串并且这个串最多分成k ...
- 【BZOJ4606】[Apio2008]DNA DP
[BZOJ4606][Apio2008]DNA Description 分析如DNA序列这样的生命科学数据是计算机的一个有趣应用.从生物学的角度上说,DNA 是一种由腺嘌呤.胞嘧啶.鸟嘌呤和胸腺嘧啶这 ...
- [APIO2008]DNA 题解
题目链接 首先呢,看到 A C G T 对应不同的权值,第一步就是把字母转换成数字. 我们分别对 A->1 C->2 G->3 T->4 进行标号,之后方便 \(\text{d ...
- [APIO2008]DNA
https://zybuluo.com/ysner/note/1158123 题面 戳我 解析 我们要求出第\(r\)种方案,莫过于看其前面什么时候有\(r-1\)种方案. 于是,我们要求出每种情况的 ...
- bzoj AC倒序
Search GO 说明:输入题号直接进入相应题目,如需搜索含数字的题目,请在关键词前加单引号 Problem ID Title Source AC Submit Y 1000 A+B Problem ...
- [LeetCode] Repeated DNA Sequences 求重复的DNA序列
All DNA is composed of a series of nucleotides abbreviated as A, C, G, and T, for example: "ACG ...
- DNA解链统计物理
来源:Kerson Huang, Lectures on Statistical Physics and Protein Folding, pp 24-25 把双链DNA解开就像拉拉链.设DNA有\( ...
- AC自动机+DP HDOJ 2457 DNA repair(DNA修复)
题目链接 题意: 给n串有疾病的DNA序列,现有一串DNA序列,问最少修改几个DNA,能使新的DNA序列不含有疾病的DNA序列. 思路: 构建AC自动机,设定end结点,dp[i][j]表示长度i的前 ...
- [Leetcode] Repeated DNA Sequences
All DNA is composed of a series of nucleotides abbreviated as A, C, G, and T, for example: "ACG ...
随机推荐
- 一款纯HTML+CSS+JS富文本编辑器-handyeditor
官网:http://he.catfish-cms.com/ 修改版本(修改一些BUG和图片上传服务器 点击下载: handyeditor富文本编辑器.zip): 图片上传接口上传类型: Content ...
- #AOS应用基础平台# 实现了在用户权限范围内自己定义的快捷菜单的导航展示
from=501" style="color:rgb(255,131,115); padding:0px; margin:0px; font-family:微软雅黑,Verdana ...
- mysql中explain
1.select_type: /* select_type 使用 SIMPLE */explain select * from tb_shop_order where id='201603292570 ...
- [转]java线程安全、jstack\线程dump、内存查看分析总结
http://jameswxx.iteye.com/blog/808546 java线程安全总结二 http://jameswxx.iteye.com/blog/1041173 jstack和线程du ...
- Greenplum-cc-web监控软件安装
一环境列表 操作系统 centos6.5 64 Greenplum版本: greenplum-db-4.3.5.3-build-2-RHEL5-x86_64.tar Greenplum集群环境搭建: ...
- lrzsz离线安装方法
lrzsz离线安装方法 到网上下载lrzsz安装包,这里以lrzsz-0.12.20.tar.gz为例 2 打开终端 cd 到安装包所在目录 tar zxvf lrzsz-0.12.20.tar.gz ...
- InstallShield 制作MSI
1. click [project Assistant] 2. select [Build Installation], open this tab asfollow: 3.whenbuild ok ...
- 修复日志,阻止给日志多次添加handlers时候重复打印的问题
1.解决如果多次添加handlers重复打印的问题.在__add_handlers方法中作出判断. 2.由get_logger_and_add_handlers和get_logger_without_ ...
- The confusion about jsp four scopes and ServletContext,HttpSession,HttpServletReqest,PageContext
The jsp four scopes are same with ServletContext,HttpSession,HttpServletRequest,PageContext? How ser ...
- The list of pre-build cross-compiler
Recently, I need compile toybox and busybox for my router. This is a list of cross-compiler for MIPS ...