枚举子序列的末尾,递推。

方案数: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的更多相关文章

  1. Codeforces 597C. Subsequences (树状数组+dp)

    题目链接:http://codeforces.com/contest/597/problem/C 给你n和数(1~n各不同),问你长为k+1的上升自序列有多少. dp[i][j] 表示末尾数字为i 长 ...

  2. CodeForces - 597C Subsequences (树状数组+动态规划)

    For the given sequence with n different elements find the number of increasing subsequences with k + ...

  3. CodeForces - 597C Subsequences 【DP + 树状数组】

    题目链接 http://codeforces.com/problemset/problem/597/C 题意 给出一个n 一个 k 求 n 个数中 长度为k的上升子序列 有多少个 思路 刚开始就是想用 ...

  4. codeforces 497E Subsequences Return

    codeforces 497E Subsequences Return 想法 做完这题,学了一些东西. 1.求一个串不同子序列个数的两种方法.解一 解二 2.这道题 \(n\) 很大,很容易想到矩阵加 ...

  5. codeforces 597C C. Subsequences(dp+树状数组)

    题目链接: C. Subsequences time limit per test 1 second memory limit per test 256 megabytes input standar ...

  6. CodeForces - 597C:Subsequences (主席树+DP)

    For the given sequence with n different elements find the number of increasing subsequences with k + ...

  7. codeforces 597C (树状数组+DP)

    题目链接:http://codeforces.com/contest/597/problem/C 思路:dp[i][j]表示长度为i,以j结尾的上升子序列,则有dp[i][j]= ∑dp[i-1][k ...

  8. CodeForces - 1183E Subsequences (easy version) (字符串bfs)

    The only difference between the easy and the hard versions is constraints. A subsequence is a string ...

  9. codeforces#1183H. Subsequences(字符串dp)

    题目链接: http://codeforces.com/contest/1183/problem/H 题意: 给出一个长度为$n$的字符串,得到$k$个子串,子串$s$的花费是$n-|s|$ 计算最小 ...

随机推荐

  1. 如何在新导入的python项目中一次性生成依赖的第三方库

    requirements.txt用来记录项目所有的依赖包和版本号,只需要一个简单的pip命令就能完成. pip freeze >requirements.txt 然后就可以用 pip insta ...

  2. PIE SDK矢量数据的查询

    1.功能简介 矢量数据查询有属性查询和空间几何查询,下面对矢量数据的属性查询和空间查询做介绍 2.功能实现说明 2.1. 矢量数据的属性和空间查询 2.2. 实现思路及原理说明 第一步 得到要查询的图 ...

  3. TT8509: PL/SQL execution terminated; PLSQL_TIMEOUT exceeded

    TT8509: PL/SQL execution terminated; PLSQL_TIMEOUT exceeded plsql_timeout连接超时,解决办法: ODBC pl/sql选项卡 修 ...

  4. 全文检索~solr的使用

    全文检索这个系列在几前年写过lucene的文章,而现在看来它确实已经老了,它的儿子孙子都出来了,已经成为现在检索行列的主流,像solr,elasticsearch等,今天我们主要来看一个solr在as ...

  5. Oracle关于All和Any

    简单的说 All等价于N个And语句,Any等价于N个or语句.

  6. 【IP】Linux中检测IP地址冲突

    在Windows系统中,如果本地网络IP地址出现冲突,会出现图标提示. 在Linux系统中,并没有提供相关的功能,如果本地网络采用静态IP地址配置,出现比较奇怪的网络连接问题,如ssh连接复位,可以考 ...

  7. LintCode刷题小记491

    题目: 判断一个正整数是不是回文数. 回文数的定义是,将这个数反转之后,得到的数仍然是同一个数. 样例: 11, 121, 1, 12321 这些是回文数. 23, 32, 1232 这些不是回文数. ...

  8. My eclipse jdk unbound的解决

    project --> properties --> java build path --> 双击出错的jdk --> alternate jre --> install ...

  9. mysql无法连接Can't create a new thread (errno 11)

    问题描述: 今天本地navicat连接服务器mysql出错 ,提示ERROR 1135: Can't create a new thread (errno 11); if you are not ou ...

  10. HIVE的sql语句操作

    Hive 是基于Hadoop 构建的一套数据仓库分析系统,它提供了丰富的SQL查询方式来分析存储在hadoop 分布式文件系统中的数据,可以将结构 化的数据文件映射为一张数据库表,并提供完整的SQL查 ...