Problem UVA10410-Tree Reconstruction Accept:708 Submit:4330 Time Limit: 3000 mSec Problem Description You have just finished a compiler design homework question where you had to find the parse tree of an expression. Unfortunately you left your assig…
Tree chain problem Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 1798 Accepted Submission(s): 585 Problem Description Coco has a tree, whose vertices are conveniently labeled by 1,2,…,n.The…
Query on A Tree Time Limit: 20000/10000 MS (Java/Others) Memory Limit: 132768/132768 K (Java/Others) Total Submission(s): 712 Accepted Submission(s): 266 Problem Description Monkey A lives on a tree, he always plays on this tree. One day, monke…
Tree and Queries 题意:有一颗以1号节点为根的树,每一个节点有一个自己的颜色,求出节点v的子数上颜色出现次数>=k的颜色种类. 题解:使用莫队处理这个问题,将树转变成DFS序区间,然后就是开一个数据记录下出现次数为k次的颜色数目,查询的时候直接返回这个数组中的对应的值就行了. 注意的就是记得将节点的颜色传递给dfs序对应位置的颜色. 这个忘记了找了好久的bug. 代码: #include<bits/stdc++.h> using namespace std; #defin…
S - Query on a tree HDU - 3804 离散化+权值线段树 题目大意:给你一棵树,让你求这棵树上询问的点到根节点直接最大小于等于val的长度. 这个题目和之前写的那个给你一棵树询问这棵树的这个节点到根节点之间的节点权重相乘小于等于k的对数非常像. 之前是不是就是放进去弹出来的操作,这个也是一样,之前用的是离散化逆序对的思想来求,这个开始没有想到. 然后自己写了一个很暴力的线段树,线段树要是没有一个连续的区间是有很高复杂度的. 所以要想办法把这个转化成一个连续的区间,这个…
为熟悉机房键盘而划水 #include <bits/stdc++.h> using namespace std; #define int long long const int N = 4000005; int R; namespace seg { int a[N], src[N]; void pushup(int p) { a[p] = a[p * 2] + a[p * 2 + 1]; } void build(int p, int l, int r) { if (l == r) { a[p…
题目描述 现在有一颗以1为根节点的由n个节点组成的树,树上每个节点上都有一个权值vi. 现在有Q 次操作,操作如下: 1 x y 查询节点x的子树中与y异或结果的最大值 2 x y z 查询路径x到y上点与z异或结果最大值 输入 第一行是两个数字n, Q; 第二行是n个数字用空格隔开,第i个数字vi表示点i上的权值 接下来n-1行,每行两个数,x,y,表示节点x与y之间有边 接下来Q行,每一行为一个查询,格式如上所述. 1 < n, Q ≤ 100000 ,查询1中的y ≤ 2…
A. Alex and broken contest time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output One day Alex was creating a contest about his friends, but accidentally deleted it. Fortunately, all the problems…
D. Tree Requests time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Roman planted a tree consisting of n vertices. Each vertex contains a lowercase English letter. Vertex 1 is the root of the…
Apple Tree Time Limit: 2000MS Memory Limit: 65536K Description There is an apple tree outside of kaka's house. Every autumn, a lot of apples will grow in the tree. Kaka likes apple very much, so he has been carefully nurturing the big apple t…
Apple Tree Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 26762 Accepted: 7947 Description There is an apple tree outside of kaka's house. Every autumn, a lot of apples will grow in the tree. Kaka likes apple very much, so he has been…
C. Propagating tree Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/383/problem/C Description Iahub likes trees very much. Recently he discovered an interesting tree named propagating tree. The tree consists of n nodes numb…
Tree You are to determine the value of the leaf node in a given binary tree that is the terminal node of a path of least value from the root of the binary tree to any leaf. The value of a path is the sum of values of nodes along that path.Input The i…
D. Water Tree Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/343/problem/D Description Mad scientist Mike has constructed a rooted tree, which consists of n vertices. Each vertex is a reservoir which can be either empty or…