dp
xiaoyu1_1
学生
展开
-
HDU 1520 Anniversary party-----树形DP
dp[i][0]表示 i点 不取 dp[i][1]表示 i点取 j为i的子节点 则 dp[i][0] += max(dp[j][0],dp[j][1]); dp[i][1] += dp[j][0]; (j 子节点有很多) 如果 a 为根节点,结果就是 max(dp[a][0],dp[a][1]); 用 vector 写得邻接表。。 #include #原创 2013-07-04 19:17:43 · 572 阅读 · 0 评论 -
hdu-1074-Doing Homework
状态压缩dp.. #include #include #include #include #include using namespace std; #define inf 0x3f3f3f3f struct node { int d,c; char ch[110]; }p[20]; int n; bool cmp(node a,node b) { return strcmp(a.ch,原创 2014-02-15 01:10:23 · 778 阅读 · 0 评论 -
hdu-4778-Gems Fight!---状态压缩dp
http://blog.csdn.net/dyx404514/article/details/15506601 http://blog.csdn.net/catalyst1314/article/details/19012251 链接里看的思路,然后写了一下午,晚上改了2个BUG.... #include #include #include #include using namespac原创 2014-02-11 00:10:50 · 544 阅读 · 0 评论 -
poj 2096 Collecting Bugs 概率dp入门题
http://blog.csdn.net/youngyangyang04/article/details/8117561 不明觉厉 #include #include #include #include #include using namespace std; #define inf 0x3f3f3f3f #define ll __int64 double dp[1005][1005];转载 2014-02-24 12:52:56 · 575 阅读 · 0 评论 -
hdu-2167-Pebbles--炮兵布阵之类的 状态压缩dp
呵呵,思路清晰爆了,瞬写 #include #include #include #include using namespace std; char ch[100]; int map[16][16]; int s[10000],c[16][10000]; int dp[16][10000]; int n; int count(int h,int x) { int i,sum=0; for(原创 2014-02-10 20:41:42 · 487 阅读 · 0 评论 -
hdu-4539-郑厂长系列故事――排兵布阵 状态压缩dp
http://blog.csdn.net/catalyst1314/article/details/19015401 http://blog.csdn.net/z309241990/article/details/8742321 #include #include #include #include using namespace std; int e[220],s[220],c原创 2014-02-10 10:23:36 · 798 阅读 · 0 评论 -
poj 4604 Deque-----2013多校联合赛第一场--1005
做了一天,终于做出来了。。 结题报告:考虑题目的一个简化版本:使双端队列单调上升。对于序列 A 和队列 Q,找到队列中最早出 现的数字Ax,则Ax将 Q 分成的两个部分分别是原序列中以Ax开始的最长上升和最长下降序 列,答案即为这两者之和的最大值。而对于本题,由于存在相同元素,所以只要找到以Ax 为起点的最长不下降序列和最长不上升序列的和,然后减去两个里面出现Ax次数的最小值 即可。原创 2013-07-24 20:28:49 · 552 阅读 · 0 评论 -
hdu 1069 Monkey and Banana---dp(也可用 求最长路+floyd水过)
把每个方块,当成3个点,地面设为p[0] 点,有向图的 最长路,用 floyd 水过 其实应该用 dp 做的。。 #include #include #include #include #include #include using namespace std; int n,i,j,k; struct node{ int a,b,len; }p[100]; int原创 2013-07-05 13:44:13 · 1120 阅读 · 0 评论 -
HDU 1081 To The Max ---二维dp
给一段数列,求连续数列 和的最大值, 此题是二维的,将 i行到 j行 相加,转换为一行了,就是一维的了 #include #include #include using namespace std; int p[110][110],b[110]; int n; int com(int *b) //算一维的 函数 { int i,j,k,sum=0,max=-1原创 2013-07-05 13:54:00 · 490 阅读 · 0 评论 -
Codeforces Round #235 (Div. 2) ----D. Roman and Numbers
D. Roman and Numbers time limit per test 4 seconds memory limit per test 512 megabytes input standard input output standard output Roman is a young mathematician, very f原创 2014-03-11 23:12:12 · 658 阅读 · 0 评论