codeforces 597C - Subsequences
枚举子序列的末尾,递推。
方案数:f[i = 以i结尾][k =子序列长度] = sum(f[j][k-1]),j < i。
转移就建立k个BIT。
#include<bits/stdc++.h>
using namespace std; typedef long long ll; const int N = 1e5+, K = ; ll C[K][N]; ll sum(ll C[],int x)
{
ll re = ;
while(x > ){
re += C[x]; x &= x-;
}
return re;
} int n;
void add(ll C[],int x,ll d)
{
while(x <= n){
C[x] += d; x += x&-x;
}
} //#define LOCAL
int main()
{
#ifdef LOCAL
freopen("in.txt","r",stdin);
#endif
int k;
cin>>n>>k;
if(k == ) { cout<<n; return ;}
k--;
ll ans = ;
for(int i = ,j,x; i < n; i++){
scanf("%d",&x);
ans += sum(C[k],x);
for(j = k; j > ; j--){
add(C[j],x,sum(C[j-],x));
}
add(C[],x,);
}
cout<<ans<<endl;
return ;
}
codeforces 597C - Subsequences的更多相关文章
- Codeforces 597C. Subsequences (树状数组+dp)
题目链接:http://codeforces.com/contest/597/problem/C 给你n和数(1~n各不同),问你长为k+1的上升自序列有多少. dp[i][j] 表示末尾数字为i 长 ...
- CodeForces - 597C Subsequences (树状数组+动态规划)
For the given sequence with n different elements find the number of increasing subsequences with k + ...
- CodeForces - 597C Subsequences 【DP + 树状数组】
题目链接 http://codeforces.com/problemset/problem/597/C 题意 给出一个n 一个 k 求 n 个数中 长度为k的上升子序列 有多少个 思路 刚开始就是想用 ...
- codeforces 497E Subsequences Return
codeforces 497E Subsequences Return 想法 做完这题,学了一些东西. 1.求一个串不同子序列个数的两种方法.解一 解二 2.这道题 \(n\) 很大,很容易想到矩阵加 ...
- codeforces 597C C. Subsequences(dp+树状数组)
题目链接: C. Subsequences time limit per test 1 second memory limit per test 256 megabytes input standar ...
- CodeForces - 597C:Subsequences (主席树+DP)
For the given sequence with n different elements find the number of increasing subsequences with k + ...
- codeforces 597C (树状数组+DP)
题目链接:http://codeforces.com/contest/597/problem/C 思路:dp[i][j]表示长度为i,以j结尾的上升子序列,则有dp[i][j]= ∑dp[i-1][k ...
- CodeForces - 1183E Subsequences (easy version) (字符串bfs)
The only difference between the easy and the hard versions is constraints. A subsequence is a string ...
- codeforces#1183H. Subsequences(字符串dp)
题目链接: http://codeforces.com/contest/1183/problem/H 题意: 给出一个长度为$n$的字符串,得到$k$个子串,子串$s$的花费是$n-|s|$ 计算最小 ...
随机推荐
- Spark (Python版) 零基础学习笔记(一)—— 快速入门
由于Scala才刚刚开始学习,还是对python更为熟悉,因此在这记录一下自己的学习过程,主要内容来自于spark的官方帮助文档,这一节的地址为: http://spark.apache.org/do ...
- css display flew 伸缩盒模型
父级容器属 <!doctype html> <html lang="en"> <head> <meta charset="UTF ...
- GreenPlum 大数据平台--备份-邮件配置-gpcrondump & gpdbrestore(五)
01,备份 生成备份数据库 [gpadmin@greenplum01 ~]$ gpcrondump -l /gpbackup/back2/gpcorndump.log -x postgres -v [ ...
- Go初探
官方网站:https://golang.org/ 标准库文档:https://golang.org/pkg/ 在线编码学习:https://play.golang.org/ PS:请自行FQ 简介 ...
- nodejs初探(一)nodejs开发环境搭建
简介 JavaScript是一种运行在浏览器的脚本.Node.js是一个基于Chrome JavaScript运行时建立的平台, 用于方便地搭建响应速度快.易于扩展的网络应用.Node.js 使用事件 ...
- Become a Better Programmer: 5 Essential Methods at a Glance--reference
http://www.git-tower.com/blog/become-a-better-programmer-5-essentials/ Become a Better Programmer: 5 ...
- 两个三汇API使用的坑
最近呼叫中心走火入魔了,我的<一步一步开发呼叫中心>系列编写过程中,遇到各种的问题,今天晚上,来记录一下纠结了我N久的一个问题: 内线通过板卡外呼时,如果对方的呼叫中心需要发送按键响应(如 ...
- BulletedList用途
1.用作最普通的信息显示(列表方式) 2.制作导航条 BulletedList3中模式 1.Text 文本 2.HyperLink 连接 2.LinkButton 按钮 BulletedList 导航 ...
- MVC5 model常见的写法
1.数据库表中为ID的字段 [Key] //关键字 [Required] //不为空 [Display(Name = "ID")] public int id { get; set ...
- Css:Conditional comments 条件注释
http://msdn.microsoft.com/en-us/library/ms537512(VS.85).aspx http://www.quirksmode.org/css/condcom.h ...