随笔分类 - ACM-动态规划-基础DP
摘要:CodeForces - 597C Subsequences 一拿到这个题感觉很新颖,不过没啥思路。 看了大家的题解,一个$O(n^2\times k)$的做法还是能写一写,虽然过不了。 因为本题所有数字是个全排列,我们设状态是$dp[i][j]$,表示长度为$i$的子序列,以$j$结尾的方案数。
阅读全文
摘要:CodeForces 628E Zbazi in Zeydabad 这个树状数组很巧妙。 将$O(n^3)$降到$O(n^2logn)$。 每个对角线的加和相等,建在一棵树上。 #include <bits/stdc++.h> using namespace std; const int maxn
阅读全文
摘要:CodeForces 608C Chain Reaction #include <bits/stdc++.h> using namespace std; const int maxn = 1e6 + 50; int cov[100010]; ///覆盖个数 int sum[maxn]; struct
阅读全文
摘要:http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1201 DP转移方程:dp[i][j] = dp[i-j][j]+dp[i-j][j-1]; dp[i][j] 表示将i分成j个不相等的数的个数。 dp[i-j][j]-->
阅读全文
摘要:#include #include #include #include using namespace std; const int maxn = 1e3+5; int dp[maxn][maxn]; char s1[maxn]; char p[maxn]; int main() { int T;cin>>T; while(T--) { int n...
阅读全文
摘要:C. Reberland Linguistics time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output First-rate speci
阅读全文
摘要:C. Coloring Trees time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output ZS the Coder and Chris
阅读全文
摘要:2016 Multi-University Training Contest 1 这次比赛名次算是目前来最好的一次了,总共A了6题,几乎全是dp题。真是佩服一神。 HDU5763 Another Meaning (kmp+dp) 这道题开场后五分钟一神就给我们过来讲解法,我思考了好一会儿才理解。 k
阅读全文
摘要:P1084 数字三角形4 题解:dp+dfs. #include <iostream> #include <cstdio> #include <algorithm> #include <cstring> using namespace std; const int maxn = 40; int dp
阅读全文
摘要:从最简单的开始: POJ:The Triangle #include <cstdio> #include <algorithm> #include <cstring> using namespace std; int dp[111][111]; int a[111][111]; int main()
阅读全文
摘要:Partial Tree Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 823 Accepted Submission(s): 407 Pr
阅读全文
摘要:In Action Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 5220 Accepted Submission(s): 1745 Probl
阅读全文
摘要:Employment Planning Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 4782 Accepted Submission(s):
阅读全文
摘要:Tickets Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 2694 Accepted Submission(s): 1308 Problem
阅读全文
摘要:Super Jumping! Jumping! Jumping! Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 31490 Accepted S
阅读全文
摘要:FatMouse's Speed Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 13643 Accepted Submission(s): 60
阅读全文
摘要:FatMouse and Cheese Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 7576 Accepted Submission(s):
阅读全文
摘要:Monkey and Banana Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 11391 Accepted Submission(s): 5
阅读全文
摘要:Problem Description CA is a fine comrade who loves the party and people; inevitably she loves GCD (greatest common divisor) too. Now, there are N diff
阅读全文