随笔分类 -  树形DP

POJ 1655 Balancing Act (求树的重心)
摘要:Balancing ActTime Limit:1000MSMemory Limit:65536KTotal Submissions:7859Accepted:3210DescriptionConsider a tree T with N (1 8 #include 9 #include 10 #include 11 #include 12 #include 13 #include 14 #include 15 #include 16 #include 17 #include 18 #include 19 using namespace std;20 const int MAXN = 20.. 阅读全文

posted @ 2013-11-16 22:34 kuangbin 阅读(2799) 评论(0) 推荐(1)

HDU 4123 Bob’s Race(树形DP,rmq)
摘要:Bob’s RaceTime Limit: 5000/2000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1994Accepted Submission(s): 619Problem DescriptionBob wants to hold a race to encourage people to do sports. He has got trouble in choosing the route. There are N houses and N - 1 roads in h 阅读全文

posted @ 2013-11-08 18:27 kuangbin 阅读(1490) 评论(0) 推荐(0)

HDU 4714 Tree2cycle (树形DP)
摘要:Tree2cycleTime Limit: 15000/8000 MS (Java/Others)Memory Limit: 102400/102400 K (Java/Others)Total Submission(s): 324Accepted Submission(s): 54Problem DescriptionA tree with N nodes and N-1 edges is given. To connect or disconnect one edge, we need 1 unit of cost respectively. The nodes are labeled f 阅读全文

posted @ 2013-09-08 19:51 kuangbin 阅读(1272) 评论(0) 推荐(0)

HDU 4705 Y (2013多校10,1010题,简单树形DP)
摘要:YTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 60Accepted Submission(s): 20Problem DescriptionSample Input41 21 31 4Sample Output1Hint1. The only set is {2,3,4}.2. Please use #pragma comment(linker, "/STACK:16777216")Source2013 Multi- 阅读全文

posted @ 2013-08-22 18:24 kuangbin 阅读(851) 评论(0) 推荐(0)

HDU 4679 Terrorist’s destroy (2013多校8 1004题 树形DP)
摘要:Terrorist’s destroyTime Limit: 6000/3000 MS (Java/Others)Memory Limit: 65535/32768 K (Java/Others)Total Submission(s): 24Accepted Submission(s): 6Problem DescriptionThere is a city which is built like a tree.A terrorist wants to destroy the city's roads. But now he is alone, he can only destroy 阅读全文

posted @ 2013-08-15 17:09 kuangbin 阅读(1095) 评论(6) 推荐(1)

HDU 3534 Tree (树形DP)
摘要:题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3534题意:给出一颗树(n个顶点,n-1条边)求最长的路径,以及最长路径的条数。路径无非就是连接两个点直接的路。因为是一颗树,所以连接两个点肯定是唯一的路径。其实就是求两点间距离的最大值,以及这个最大值有多少个。很裸的树形DP;首先统计出结点到叶子结点的最长距离和次长距离。然后找寻经过这个点的,在这个为根结点的子树中的最长路径个数目。代码:#include <string.h>#include <iostream>#include <algorithm>#incl 阅读全文

posted @ 2013-05-29 00:15 kuangbin 阅读(716) 评论(0) 推荐(0)

HDU 4118 Holiday's Accommodation(树形DP)
摘要:/*#pragma comment(linker, "/STACK:10240000000000,10240000000000")*/#include<stdio.h>#include<algorithm>#include<iostream>#include<string.h>using namespace std;const int MAXN=200010;struct Node{ int to,next; int len;}edge[MAXN*2];int head[MAXN];int tol;int num[MAXN]; 阅读全文

posted @ 2012-10-05 15:04 kuangbin 阅读(1264) 评论(0) 推荐(1)

HDU 4276 The Ghost Blows Light 第37届ACM/ICPC长春赛区1010题 (树形DP)
摘要:The Ghost Blows LightTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 590Accepted Submission(s): 194Problem DescriptionMy name is Hu Bayi, robing an ancient tomb in Tibet. The tomb consists of N rooms (numbered from 1 to N) which are connected by so 阅读全文

posted @ 2012-09-11 11:13 kuangbin 阅读(751) 评论(0) 推荐(0)

HDU 3586 Information Disturbing(二分答案+树形DP)
摘要:Information DisturbingTime Limit: 6000/3000 MS (Java/Others)Memory Limit: 131072/65536 K (Java/Others)Total Submission(s): 844Accepted Submission(s): 304Problem DescriptionIn the battlefield , an effective way to defeat enemies is to break their communication system.The information department told y 阅读全文

posted @ 2012-08-29 21:29 kuangbin 阅读(537) 评论(0) 推荐(0)

HDU 4044 GeoDefense(树形DP+分组背包)
摘要:GeoDefenseTime Limit: 12000/5000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 347Accepted Submission(s): 138Problem DescriptionTower defense is a kind of real-time strategy computer games. The goal of tower defense games is to try to stop enemies from reaching your b 阅读全文

posted @ 2012-08-29 20:30 kuangbin 阅读(1214) 评论(2) 推荐(0)

HDU 4003 Find Metal Mineral(树形DP+分组背包)
摘要:Find Metal MineralTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 65768/65768 K (Java/Others)Total Submission(s): 1441Accepted Submission(s): 631Problem DescriptionHumans have discovered a kind of new metal mineral on Mars which are distributed in point‐like with paths connecting each of them wh 阅读全文

posted @ 2012-08-29 13:25 kuangbin 阅读(2009) 评论(0) 推荐(0)

HDU 1561 The more, The Better(树形DP+分组背包)
摘要:The more, The BetterTime Limit: 6000/2000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 3149Accepted Submission(s): 1857Problem DescriptionACboy很喜欢玩一种战略游戏,在一个地图上,有N座城堡,每座城堡都有一定的宝物,在每次游戏中ACboy允许攻克M个城堡并获得里面的宝物。但由于地理位置原因,有些城堡不能直接攻克,要攻克这些城堡必须先攻克其他某一个特定的城堡。你能帮ACboy算出要获得尽量多 阅读全文

posted @ 2012-08-29 12:12 kuangbin 阅读(543) 评论(0) 推荐(0)

HDU 1011 Starship Troopers(树形DP)
摘要:Starship TroopersTime Limit: 10000/5000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 5726Accepted Submission(s): 1529Problem DescriptionYou, the leader of Starship Troopers, are sent to destroy a base of the bugs. The base is built underground. It is actually a huge 阅读全文

posted @ 2012-08-28 23:38 kuangbin 阅读(1193) 评论(0) 推荐(0)

HDU 2196 Computer(树形DP)
摘要:ComputerTime Limit: 1000/1000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1232Accepted Submission(s): 597Problem DescriptionA school bought the first computer some time ago(so this computer's id is 1). During the recent years the school bought N-1 new computers. 阅读全文

posted @ 2012-08-28 11:10 kuangbin 阅读(4455) 评论(0) 推荐(2)

HDU 1520 Anniversary party(简单树形DP)
摘要:Anniversary partyTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 2124Accepted Submission(s): 896Problem DescriptionThere is going to be a party to celebrate the 80-th Anniversary of the Ural State University. The University has a hierarchical struc 阅读全文

posted @ 2012-08-28 09:35 kuangbin 阅读(3543) 评论(0) 推荐(0)

HDU 1054 Strategic Game(树形DP)
摘要:Strategic GameTime Limit: 20000/10000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 2925Accepted Submission(s): 1222Problem DescriptionBob enjoys playing computer games, especially strategic games, but sometimes he cannot find the solution fast enough and then he is v 阅读全文

posted @ 2012-08-19 22:18 kuangbin 阅读(664) 评论(1) 推荐(0)

HDU 1011 Starship Troopers(树形DP)
摘要:Starship TroopersTime Limit: 10000/5000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 4118Accepted Submission(s): 1076Problem DescriptionYou, the leader of Starship Troopers, are sent to destroy a base of the bugs. The base is built underground. It is actually a huge 阅读全文

posted @ 2012-03-14 19:00 kuangbin 阅读(3722) 评论(3) 推荐(0)

导航

JAVASCRIPT: