题目链接:http://codeforces.com/contest/597/problem/C 思路:dp[i][j]表示长度为i,以j结尾的上升子序列,则有dp[i][j]= ∑dp[i-1][k](1<=k<j),由于要求前缀和,可以用树状数组优化 #include<bits/stdc++.h> #define lowbit(x) x&(-x) typedef long long ll; const int N=1e5+3; ll dp[12][N]; using n…
题目链接: C. Subsequences time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output For the given sequence with n different elements find the number of increasing subsequences with k + 1 elements. It is…
For the given sequence with n different elements find the number of increasing subsequences with k + 1elements. It is guaranteed that the answer is not greater than 8·1018. Input First line contain two integer values n and k (1 ≤ n ≤ 105, 0 ≤ k ≤ 10)…
For the given sequence with n different elements find the number of increasing subsequences with k + 1 elements. It is guaranteed that the answer is not greater than 8·1018. Input First line contain two integer values n and k (1 ≤ n ≤ 105, 0 ≤ k ≤ 10…
D. Zip-line 题目连接: http://www.codeforces.com/contest/650/problem/D Description Vasya has decided to build a zip-line on trees of a nearby forest. He wants the line to be as long as possible but he doesn't remember exactly the heights of all trees in t…
https://codeforces.com/contest/1194/problem/C 好像没什么好说的,要能构造s必须是t的子序列,并且相差的字符集合d是p的子集. 用双指针法求两遍子序列就可以了,甚至不需要sort,假如用桶排的话就是O(qn)的. 下面这个错在哪里呢? 正确的: #include<bits/stdc++.h> using namespace std; typedef long long ll; int n; char s[105]; char t[105]; char…
题目链接:https://codeforces.com/contest/1427/problem/C 题意 \(r\) 行与 \(r\) 列相交形成了 \(r \times r\) 个点,初始时刻记者位于左下角的 \((1,1)\) 处,接下来给出 \(n\) 个名人的出现时间和位置,出现时间严格递增,问记者最多可以拍到多少名人的照片. 题解 This is a classical dynamic-programming task with a twist. 这是一个有些变化的经典动态规划问题.…
D. Bubble Sort Graph time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Iahub recently has learned Bubble Sort, an algorithm that is used to sort a permutation with n elements a1, a2, ..., an …
A. Anastasia and pebbles time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Anastasia loves going for a walk in Central Uzhlyandian Park. But she became uninterested in simple walking, so she…
E. Weakness and Poorness time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output You are given a sequence of n integers a1, a2, ..., an. Determine a real number x such that the weakness of the seq…
D. Once Again... You are given an array of positive integers a1, a2, ..., an × T of length n × T. We know that for any i > n it is true that ai = ai - n. Find the length of…