题目链接:http://acm.uestc.edu.cn/#/problem/show/1217 给你一个长为n的数组,问你有多少个长度严格为m的上升子序列. dp[i][j]表示以a[i]结尾长为j的上升子序列个数.常规是三个for. 这里用树状数组优化一下,类似前缀和的处理,两个for就好了. //#pragma comment(linker, "/STACK:102400000, 102400000") #include <algorithm> #include &l…
The Battle of Chibi Cao Cao made up a big army and was going to invade the whole South China. Yu Zhou was worried about it. He thought the only way to beat Cao Cao is to have a spy in Cao Cao's army. But all generals and soldiers of Cao Cao were loya…
Cao Cao made up a big army and was going to invade the whole South China. Yu Zhou was worried about it. He thought the only way to beat Cao Cao is to have a spy in Cao Cao's army. But all generals and soldiers of Cao Cao were loyal, it's impossible t…
传送门 比 P1439 排列LCS问题,难那么一点点,只不过有的元素不是两个串都有,还有数据范围变大,树状数组得打离散化. 不过如果用栈+二分的话还是一样的. ——代码 #include <cstdio> #include <algorithm> ; int n, m, size, ans; ], q[MAXN << ], p[MAXN << ]; inline int max(int x, int y) { return x > y ? x : y;…
The Battle of Chibi Cao Cao made up a big army and was going to invade the whole South China. Yu Zhou was worried about it. He thought the only way to beat Cao Cao is to have a spy in Cao Cao's army. But all generals and soldiers of Cao Cao were loya…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5542 Problem DescriptionCao Cao made up a big army and was going to invade the whole South China. Yu Zhou was worried about it. He thought the only way to beat Cao Cao is to have a spy in Cao Cao's army.…
Increasing Speed Limits Time Limit: 2000/10000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 481    Accepted Submission(s): 245 Problem Description You were driving along a highway when you got caught by the road p…
题意:给定一个N个数的数列,求所有不同不下降子序列的乘积之和,其中不同指的是组成它的数字和长度不完全相同 n (1 ≤ n ≤ 10^5) a[i]<=10^6 思路:考虑DP.设DP[a[i]]为最后一位为a[i]时所有序列的积之和,则dp[a[i]]=a[i]+sigma(dp[a[j]]) *a[i] (a[j]<=a[i],j<i) 后一部分可以用树状数组计算 为了去除最后一位相同的序列比如1 2 2 这个序列中1 2这个子序列只能算一遍 要强行去掉原来最后一位为a[i]的序列…
http://acm.hdu.edu.cn/showproblem.php?pid=2227 用dp[i]表示以第i个数为结尾的nondecreasing串有多少个. 那么对于每个a[i] 要去找 <= a[i]的数字那些位置,加上他们的dp值即可. 可以用树状数组维护 #include <cstdio> #include <cstdlib> #include <cstring> #include <cmath> #include <algori…
传送门 思路 显然是树形DP,显然是斜率优化,唯一的问题就是该怎么维护凸包. 套路1:树上斜率优化,在没有这题的路程的限制的情况下,可以维护一个单调栈,每次加入点的时候二分它会加到哪里,然后替换并记录,等从这个点回溯上来的时候再撤销. 套路2:有路程限制时,不能简单替换,因为你可能会替换掉一个下面有用的点,然后WA掉.解决方法是用树状数组维护后缀单调栈,同样要支持撤销. 听着很简单,但代码不是很好写. 代码 第82行少打一个\(dep\)调了一下午,身败名裂-- #include<bits/st…