Ural 1039 Anniversary Party】的更多相关文章

POJ 2342 Anniversary party / HDU 1520 Anniversary party / URAL 1039 Anniversary party(树型动态规划) Description There is going to be a party to celebrate the 80-th Anniversary of the Ural State University. The University has a hierarchical structure of emp…
题目传送门 /* 题意:上司在,员工不在,反之不一定.每一个人有一个权值,问权值和最大多少. 树形DP:把上司和员工的关系看成根节点和子节点的关系,两者有状态转移方程: dp[rt][0] += max (dp[son][1], dp[son][0]); //上司不去 dp[rt][1] += dp[son][0]; //上司去,员工都不去 */ #include <cstdio> #include <cstring> #include <algorithm> #inc…
题目链接:http://acm.timus.ru/problem.aspx?space=1&num=1039 Dynamic Programming. 建立树形结构,每个employee有两个选择,去或者不去.supervisor的选择影响着sub-tree的选择.代码如下: #include <iostream> #include <math.h> #include <stdio.h> #include <cstdio> #include <…
http://acm.timus.ru/problem.aspx?space=1&num=1039 1039. Anniversary Party Time limit: 0.5 secondMemory limit: 8 MB Background The president of the Ural State University is going to make an 80'th Anniversary party. The university has a hierarchical st…
坑,一开始以为,分成两半的时候去最大那个就行了, 实际上这样是不对的,因为有可能出现小的一半的时间比大的要长, 因为还和等待次数有关,且转移的时候需要用到次数更小的状态, 所以状态定义为二维,dp[i][j]表示长度为i的区间,放小于等于j次的概率. 要求确切的某次的概率,比如k,就只要用dp[i][k]-dp[i][k-1]就行了. 如何转移?从小到大枚举i,从小到大枚举j,初始化dp[i][j] = dp[i][j-1], 然后求出确切等待j次的概率,以k为界限划分区间,分成l,r两段,加上…
前言:按照计划,昨天应该是完成树形DP7题和二分图.最大流基础专题,但是由于我智商实在拙计,一直在理解树形DP的思想,所以第二个专题只能顺延到今天了.但是昨天把树形DP弄了个5成懂我是很高兴的!下面我把这7题的解题思想和部分代码分享给大家. 题目一:皇宫看守问题描述:太平王世子事件后,陆小凤成了皇上特聘的御前一品侍卫.皇宫以午门为起点,直到后宫嫔妃们的寝宫,呈一棵树的形状:某些宫殿间可以互相望见.大内保卫森严,三步一岗,五步一哨,每个宫殿都要有人全天候看守,在不同的宫殿安排看守所需的费用不同.可…
C - Anniversary FireworkTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest/view.action?cid=87643#problem/B Description Denis has to prepare the Ural State University 90th anniversary firework. He bought n rockets and s…
Anniversary party Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 7230   Accepted: 4162 Description There is going to be a party to celebrate the 80-th Anniversary of the Ural State University. The University has a hierarchical structure…
树形DP....在树上做DP....不应该是猴子干的事吗?  Anniversary party Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 3563    Accepted Submission(s): 1648 Problem Description There is going to be a party to celebrat…
A - Anniversary party Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Status Practice HDU 1520 Description There is going to be a party to celebrate the 80-th Anniversary of the Ural State University. The Universit…