
二叉树
twh233
嘻嘻
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
UVA 122
Trees are fundamental in many branches of computer science (Pun definitely intended). Current stateof-the art parallel computers such as Thinking Machines’ CM-5 are based on fat trees. Quad- andoc原创 2016-12-25 11:18:21 · 265 阅读 · 0 评论 -
UVA548
大意:给定前序和后序遍历,先找出从根到叶sum最小的路径,然后输出叶子上的值,如果有多条路径满足,输出值最小的。紫书155页 代码:#include using namespace std;#define LL long long#define INF 0x3f3f3f3#define pi acos(-1)const int maxn=1e3+5;转载 2016-12-25 12:10:55 · 196 阅读 · 0 评论 -
Uva 839
UVA839代码:#include using namespace std;#define LL long long#define INF 0x3f3f3f3#define pi acos(-1)const int maxn=1e3+5;const int maxx=1e6+5;bool solve(int &W){ int W1,W2,D1,D2; b原创 2016-12-25 12:48:34 · 288 阅读 · 0 评论 -
UVA699
#include using namespace std;#define LL long long#define INF 0x3f3f3f3#define pi acos(-1)const int maxn=1e3+5;const int maxx=1e6+5;int sum[maxn];void build(int p){ int v; cin>>v;原创 2016-12-25 14:26:31 · 335 阅读 · 0 评论 -
UVA297
297紫书160页 四分树 题意很简单就不说了下面附上紫书的代码:#include using namespace std;#define LL long long#define INF 0x3f3f3f3#define pi acos(-1)const int maxn=1e3+5;const int maxx=1e6+5;const int len=3原创 2016-12-25 14:54:55 · 224 阅读 · 0 评论 -
hdu 5927
题意:给定一棵以1为根的n个节点的树,多个询问,每次询问给出一个集合,集合内的点表示为不重要的点(不在集合内的点就是重要的点),求给定这个集合后有多少点能进入另一个集合,点x进入另一个集合的要求:1:重要的点。2:有两个重要的点的最近公共祖先为x。分析:其实对于每一个询问我们只要判断哪些不重要的点是能进入集合的,那么对于一个不重要的点x,怎样才能进入集合呢?我们先dfs对于所有的点求出fa[x原创 2017-03-02 20:58:11 · 264 阅读 · 0 评论 -
树的遍历
题目链接题意是中文意思就不说明了 ,提供一个模版吧#include //#include //#include //using namespace __gnu_pbds;using namespace std;#define LL long long#define INF 1E4 * 1E9#define pi acos(-1)#define endl '\n'原创 2017-03-07 21:00:13 · 288 阅读 · 0 评论 -
Educational Codeforces Round 32 G. Xor-MST 01字典树+二叉树 (板子
https://vjudge.net/problem/CodeForces-888G题意:n个点,每个点有一个权值,现在两两连边,边权是点与点的xor值,求最小生成树。首先xor想到,是否是01字典树,从题目中最小生成树的最小大概也就猜到了要建trie树,怎么建呢,对于xor来说,高位相同越多,他们xor值变得更小,所以我们对n个点的权值可以排序,相邻的建边会更优一点,原创 2017-11-13 23:55:53 · 338 阅读 · 0 评论