随笔分类 - DP
摘要:Description You are given a rooted tree with n nodes, labeled from $1$ to \(n\). The tree is rooted at node $1$. The parent of the i-th node is \(p_i\
阅读全文
摘要:Description You are playing a computer card game called Splay the Sire. Currently you are struggling to defeat the final boss of the game. The boss ba
阅读全文
摘要:Description Input Output Solution 比较明显的DP 设$f_{i,j}$表示做到第i行,分了j个矩形的方案数 转移明显: \(f_{i,j}=max(f_{k,j-1}+(i-k)*(r_{i}-l_{i}))\) 暴力做的话是$O(n^{2}k)$的,不能接受 考虑
阅读全文
摘要:Description Input Output Solution 这题有好几个做法,这里介绍两个 Solution 1 (这似乎是网上的正解) From zsjzliziyang 设f[ i ][ j ]表示度数为1、2的点个数分别为i,j时答案。 分为下面的4种情况 1:当t2为0时我们新增若干
阅读全文
摘要:Description Original Problem Chinese Translation 大概就是给你一个间隔为1的多米诺序列,推倒一个多米诺骨牌有个花费,求推倒所有多米诺骨牌的最小花费 Solution 这道题先处理出每一个点最左及最右可推倒的位置,这可以用栈维护 设以上位置为$l_$,\
阅读全文
摘要:Problem Description Input Output 对于每组数据,输出一个整数,表示达到“平衡”状态所需的最小代价。 Data Constraint 对于20%的数据,N<=15 对于100%的数据,T<=10,N<=100,0<=si<=10000,1<=X,Y<=N,1<=Z<=1
阅读全文
摘要:题目大意 你和你的朋友有一大包糖果,你想把这些糖按照能量尽可能平均分配,输入每种糖果的个数(mid) do inc(i); while (c[j]j; if (i<r) then kp(i,r); if (l<j) then kp(l,j);end;beg...
阅读全文

浙公网安备 33010602011771号