D. How many trees? DP】的更多相关文章

C. Coloring Trees   ZS the Coder and Chris the Baboon has arrived at Udayland! They walked in the park where n trees grow. They decided to be naughty and color the trees in the park. The trees are numbered with integers from 1 to n from left to right…
题目链接:C. Coloring Trees 题意:给出n棵树的颜色,有些树被染了,有些没有.现在让你把没被染色的树染色.使得beauty = k.问,最少使用的颜料是多少.   K:连续的颜色为一组,一共有多少组. 颜料用量:p[i][j]表示第i棵树用颜料j染色 需要p[i][j]颜料. 思路:DP. dp方程:dp[i][j][k] = a 表示前i棵树beauty = j,且第j棵树染色为k时,需要的最少颜料为a. 状态转移:初始化第一棵树dp[1][1][col[1]or(1~m)].…
传送门:http://codeforces.com/problemset/problem/711/C 题目: 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 the Baboon has arrived at Udayland! They wal…
题目链接: 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 the Baboon has arrived at Udayland! They walked in the park where n trees grow. They decided…
Trees  Accepts: 156  Submissions: 533  Time Limit: 2000/1000 MS (Java/Others)  Memory Limit: 65536/65536 K (Java/Others) Problem Description Today CodeFamer is going to cut trees.There are N trees standing in a line. They are numbered from 1 to N. Th…
D. How many trees? time limit per test 1 second memory limit per test 64 megabytes input standard input output standard output In one very old text file there was written Great Wisdom. This Wisdom was so Great that nobody could decipher it, even Phon…
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 the Baboon has arrived at Udayland! They walked in the park where n trees grow. They decided to be…
D. How many trees? 题目连接: http://www.codeforces.com/contest/9/problem/D Description In one very old text file there was written Great Wisdom. This Wisdom was so Great that nobody could decipher it, even Phong - the oldest among the inhabitants of Main…
题目链接 以前做过类似的,USACO,2.3,开始数组开小了,导致数据乱了,然后超数据范围了,.. #include <cstdio> #include <iostream> #include <cmath> using namespace std; #define LL __int64 LL dp[][][]; LL c[][]; int main() { int i,j,n,k,u,h; ; i <= ; i ++) { c[i][] = ; } ; i &l…
题目链接:http://codeforces.com/problemset/problem/711/C 给你n棵树,m种颜色,k是指定最后的完美值.接下来一行n个数 表示1~n树原本的颜色,0的话就是没颜色(一定要上色),非0就是有颜色(不能上色). 接下来n行 每行m个数,第i行第j个数表示 编号为i的树上第j种颜色的代价为a[i][j]. 问你最后要使完美值为k的上色代价最小为多少,要是不可能的话就为-1. 我们来考虑dp,每个树和前一个树有联系. dp[i][j][x] 表示第i棵树 完美…