HDU 4757 Tree(可持续化字典树,lca)】的更多相关文章

题意:询问树上结点x到结点y路上上的权值异或z的最大值. 任意结点权值 ≤ 2^16,可以想到用字典树. 但是因为是询问某条路径上的字典树,将字典树可持续化,字典树上的结点保存在这条路径上的二进制数. 按照dfs序建树,结点u的字典树表示u到根结点路径上的字典树. 如果两个结点u和v,在同一条通往根结点的路径上,将会满足可减性. 因此只需要知道u.v.lca和fa[lca]四个结点的字典树就可以回答了. /*********************************************…
题目链接:点这 我的github地址:点这     Problem Description   Zero and One are good friends who always have fun with each other. This time, they decide to do something on a tree which is a kind of graph that there is only one path from node to node. First, Zero wi…
Query on A Tree 时间限制: 8 Sec  内存限制: 512 MB提交: 15  解决: 3[提交][状态][讨论版] 题目描述 Monkey A lives on a tree. He always plays on this tree.One day, monkey A learned about one of the bit-operations, xor. He was keen of this interesting operation and wanted to pr…
// hdu 1671 Phone List 字典树 // // 题目大意: // // 有一些电话号码的字符串长度最多是10,问是否存在字符串是其它字符串的前缀 // // // 解题思路: // // 字典树,先插入第一个字符串,然后依照查询,插入的方式进行訪问,发现了之后 // 就不用再进行字典树的操作了 // // // 感悟: // // 题目意思非常清楚,我在细节方面思考了非常久,插入方面在每一个串的根节点的时候加 // 上一个val值标记.查询的时候先看是否有标记,有则直接返回tr…
Tree Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=4757 Description Zero and One are good friends who always have fun with each other. This time, they decide to do something on a tree which is a kind of graph…
http://acm.hdu.edu.cn/showproblem.php?pid=4757 题意: 给出一棵树,每个结点有一个权值,现在有多个询问,每次询问包含x,y,z三个数,求出在x到y的路径上与z最大的异或值. 思路: 看着别人的代码做完这道题目之后觉得这题和主席树求第k小是异曲同工的,主席树求第k小是对每个数建立一棵线段树,也就是说第i棵线段树记录的是区间[1,i]之间的数,这样的话[l,r]这个区间内的数就在第l棵线段树和第r棵线段树之间. 回到这题上来,这题也是要在一个范围之内寻找…
Problem Description   Zero and One are good friends who always have fun with each other. This time, they decide to do something on a tree which is a kind of graph that there is only one path from node to node. First, Zero will give One an tree and ev…
Tree Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 102400/102400 K (Java/Others) Total Submission(s): 1643    Accepted Submission(s): 461 Problem Description   Zero and One are good friends who always have fun with each other. This time, t…
/******************************************************* 题目: 统计难题 (hdu 1251) 链接: http://acm.hdu.edu.cn/showproblem.php?pid=1251 算法: 字典树 提示: 这题压要用c++提交,G++会超内存 *******************************************************/ #include<cstdio> #include<cstr…
Chip Factory Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5536 Description John is a manager of a CPU chip factory, the factory produces lots of chips everyday. To manage large amounts of products, every proc…