[HDU 5542] The Battle of Chibi】的更多相关文章

题目链接:hdu 5542 首届CCPC的C题,比赛时一起搞了好久,最后是队友A出的,当时有试过用树状数组来优化 dp,然后今天下午也用树状数组搞了一下午,结果还是踩了和当时一样的坑:我总是把用来记录状态的 dp 数组和树状数组里的内置数组混在一起使用了,而且两重循环的顺序也反了,以至于两组数据 3 2               3 2 1 2 3     和     3 2 1 程序跑都得出了相同的结果,无语...之前做 dp 和线段树结合的题时也是傻傻地分不清,说到底就是 dp 的功力很不…
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.…
http://acm.hdu.edu.cn/showproblem.php?pid=5542 [题意] 给定长为n的序列,问有多少个长为m的严格上升子序列? [思路] dp[i][j]表示以a[i]结尾的长度为j的严格上升子序列有多少个 dp[i][j]=sum{dp[k][j-1]},k小于i且a[k]<a[i] 区间dp,复杂度为O(n^3) 会超时,第三层循环求和用树状数组加速 时间复杂度为O(n^2logn) 离散化的时候排序后不去重(否则WA) [Accepted] #include<…
[题目链接] 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…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5542 题目大意:在n个数中找长度为m的单调上升子序列有多少种方案 题目思路:DP,离散化,树状数组优化, dp[i][j]代表大小为i的数 长度为j时的方案,状态转移方程dp[i][j]=simiga(dp[1..i-1][j-1]) 如果直接求和的话,复杂度是n^3不行 用树状数组优化求和 复杂度n^2logn n<=1000,a[i]<=1e9,所以离散化搞一下就行 //更新一下 这题在HDU…
The Battle of Chibi Time Limit: 6000/4000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others)Total Submission(s): 591    Accepted Submission(s): 192 Problem Description Cao Cao made up a big army and was going to invade the whole South Chin…
C - The Battle of Chibi Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 无 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…
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…
The Battle of Chibi Time Limit: 6000/4000MS (Java/Others)     Memory Limit: 65535/65535KB (Java/Others) 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…