题目链接: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.…
C - The Battle of Chibi Description 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 C…
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…
The Battle of Chibi Time Limit: 6000/4000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others)Total Submission(s): 2899    Accepted Submission(s): 1043 Problem Description Cao Cao made up a big army and was going to invade the whole South Ch…
题意:给你一个n个数的序列,要求从中找出含m个数的严格递增子序列,求能找出多少种不同的方案 dp[i][j]表示以第i个数结尾,形成的严格递增子序列长度为j的方案数 那么最终的答案应该就是sigma(dp[i][m]); 显然有:dp[i][j] = sigma(dp[k][j - 1]); 其中 1 <= k < i 且 a[k] < a[i]; 题目要求严格递增,这个限制怎么解决? hdu4719这道题同样是这样处理,即我们只需要从小到大dp就行了. 但是复杂度是O(n^3)的,显然…
[题目链接] http://acm.hdu.edu.cn/showproblem.php?pid=5542 [算法] 树状数组优化DP [代码] #include<bits/stdc++.h> using namespace std; #define MAXN 1010 ; int i,j,T,TC,n,m,len,ans; int a[MAXN],tmp[MAXN],rk[MAXN]; int f[MAXN][MAXN]; class BinaryIndexedTree { private…
hdu 6200 mustedge mustedge(并查集+树状数组 或者 LCT 缩点) 题意: 给一张无向连通图,有两种操作 1 u v 加一条边(u,v) 2 u v 计算u到v路径上桥的个数 思路: 对于一颗树来说,其实就是统计u到v路径上白边的个数, 加边就是将u到v的路径上所有边都染黑,查询就是查询路径上白边的个数 由于树上每条边最多只会被修改一次,所以可以并查集暴力修改,每个点u指向祖先结点第一条白边的位置. 涂黑白边的操作对应点的子树的答案减一,可以用dfs序树状数组维护 所以…
题目链接  2017 CCPC Harbin Problem K 题意  给定若干物品,每个物品可以覆盖一个区间.现在要覆盖区间$[1, t]$. 求选出来的物品的$\frac{∑a_{i}}{∑b_{i}}$的最小值. 首先二分答案,那么每个物品的权值就变成了$x * b_{i} - a_{i}$ 在判断的时候先把那些权值为正的物品全部选出来, 然后记录一下从$1$开始可以覆盖到的最右端点的位置. 接下来开始DP,按照区间的端点升序排序(左端点第一关键字,右端点第二关键字) 问题转化为能否用剩…
题目链接   Educational Codeforces Round 39 Problem G 题意  给定一个序列,求把他变成Almost Increasing Array需要改变的最小元素个数. Almost Increasing Array为删掉至多一个元素之后可以成为严格递增子序列的数列. 这类题有个常见的套路,就是对每个元素减去下标之后求LIS. 这道题中可以删去一个元素,我们可以枚举哪个元素是被删掉的, 那么他之前的元素求LIS的时候真正的值为$a_{i} - i$,他之后的元素求…
Description \(n\) 个正整数排成一列,每个位置 \(i\) 有一个初始值 \(A_i\) 以及目标值 \(B_i\). 一次操作可以选定一个区间 \([l, r]\),并将区间内所有数赋值为 \(\max_{i\in[l, r]} A_i\). 你可以进行任意次操作,每次操作基于上次操作的结果. 求结果若干次操作后,使得与操作后的值与目标值相同的位置数最大化. Hint \(1\le n\le 10^5, 1\le A_i, B_i\le 10^9\). 原题数据过于奇妙于是就直…