首页
Python
Java
前端
数据库
Linux
Chatgpt专题
开发者工具箱
3764专题
[POJ 3764] The xor-longest Path (Tire树 + 贪心)
POJ - 3674 题意是给你一个树,每条边有一个权值,求得树上一条路径,使路径上每条边权值的异或和最大 首先用一个 DFS把根到任意点的路径的异或和求出来 xorv[i] 由异或的性质可得点 u和点 v的异或和即为 xorv[u]^xorv[v] ( 根到两点 LCA的异或和会消去) 然后问题就转化成在区间内找两个值,使得他们的异或和最大 与 LightOJ - 1269一样的做法,
阅读更多...
#trie#loj 10056 poj 3764 The XOR Largest Path
题目 在n个数中找两个数 x , y x,y x,y,使x到y的路径异或和最大 分析 可以用一种类似于差分的东西,用一个深搜求出点到根节点的异或值,然后就像The XOR Largest Pair就好了 代码 #include <cstdio>#include <bitset>#include <cstring>struct node{int y,w,next;}e[200
阅读更多...
POJ 3764 The xor-longest Path
题目描述: Time Limit: 2000MS Memory Limit: 65536KTotal Submissions: 3089 Accepted: 681 Description In an edge-weighted tree, the xor-length of a path p is defined as the xor sum of the weights
阅读更多...