POJ -- 3140】的更多相关文章

id=3140">[POJ 3140] Contestants Division(树型dp) Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 9121   Accepted: 2623 Description In the new ACM-ICPC Regional Contest, a special monitoring and submitting system will be set up, and stud…
题目链接:http://poj.org/problem?id=3140 思路:简单树形dp题,dp[u]表示以u为根的子树的人数和. #include<iostream> #include<cstdio> #include<cstring> #include<cstdlib> #include<cmath> #include<climits> #include<algorithm> #include<stack>…
Contestants Division Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 10704   Accepted: 3004 Description In the new ACM-ICPC Regional Contest, a special monitoring and submitting system will be set up, and students will be able to compete…
http://poj.org/problem?id=3140 依然是差异最小问题,不过这次是去边.思路是这样的,先记录每个点的子节点个数,然后遍历每个边. 有两个问题要注意: abs可能会出编译适配问题,可以自己写一个 INF对LL是不够用的,所以加了个INFL #include <iostream> #include <string> #include <cstring> #include <cstdlib> #include <cstdio>…
题目链接:http://poj.org/problem?id=3140 题意: 给你一棵树,问你删去一条边,形成的两棵子树的节点权值之差最小是多少. 思路: dfs #include <iostream> #include <cstdio> #include <cstring> #include <vector> using namespace std; ; typedef long long LL; int n, cnt, head[N]; LL a[N]…
Contestants Division   Description In the new ACM-ICPC Regional Contest, a special monitoring and submitting system will be set up, and students will be able to compete at their own universities. However there’s one problem. Due to the high cost of t…
题目链接 题意很扯,就是给一棵树,每个结点有个值,然后把图劈成两半,差值最小,反正各种扯. 2B错误,导致WA了多次,无向图,建图搞成了有向了.... #include <cstdio> #include <cstring> #include <iostream> #include <cmath> #include <algorithm> using namespace std; #define LL __int64 struct node {…
#include<iostream> #include<cstdio> #include<cstring> #include<string> #define MAXN 1000010 #define LL long long const LL INF = 0x7fffffffffffff; using namespace std; typedef struct{ int to,next; }Node; Node edge[*MAXN]; ],head[MAX…
本文出自   http://blog.csdn.net/shuangde800 -------------------------------------------------------------------------------------- 题目链接:poj-3140 题目 给n个节点的带权树,删掉其中一边,就会变成两颗子树,    求删去某条边使得这这两颗子树的权值之差的绝对值最小. 思路 直接dfs一次,计算所有子树的权值总和tot[i]    如果删掉一条边(v, fa),fa…
<题目链接> 题目大意:给你一棵树,让你找一条边,使得该边的两个端点所对应的两颗子树权值和相差最小,求最小的权值差. 解题分析: 比较基础的树形DP. #include <cstdio> #include <cstring> #include <algorithm> using namespace std; typedef long long ll; #define INF 0x7fffffff7fffffff #define clr(a,b) memset…