随笔分类 - XOR训练
摘要:A思路:排个序建立最短路树即可,可以双指针实现。 考察:贪心,构造。 B:显然最大值取决于a[],出现的最高位不同的那一位,假设有最高位的分到A组,不然分到B组,分组后,各取一个x,y,那么ans=min(x^y),这个可以字典树实现。 比较常规。 但是比赛的时候我以为字典树空间不够只能得80分。所
阅读全文
摘要:题意:给出A数组,B数组,你可以对A和B分别进行重排列,使得C[i]=A[i]^B[i]的字典序最小。 思路:对于这类题,显然需要建立字典树,然后某种形式取分治,或者贪心。 假设现在有了两颗字典树A,B,显然尽量让同方向的先匹配。 而且同一棵树的左右两边相互不影响,所以可以直接贪:如果A树上出发左走
阅读全文
摘要:题意:给定一棵树,有点权a[],有边权。 现在有M次修改点权的操作,输出每次修改后,Σ(a[i]^a[j])*dis(i,j); 思路:因为待修改,我们需要快速得到以及修改一个点到其他所有点的信息。 肯定就是动态点分治了啊。 而异或这个操作没有什么累加的性质,所以每一位拆开单独计算。 根据二进制位置
阅读全文
摘要:Description 对于一个长度为n的非负整数序列b_1,b_2,...,b_n,定义这个序列的能量为:f(b)=max{i=0,1,...,n}((b_1 xor b _2 xor...xor b_i)+(b_{i+1} xor b_{i+2} xor...xor b_n))其中xor表示按位
阅读全文
摘要:给出一个长度为N的正整数数组A,再给出Q个查询,每个查询包括3个数,L, R, X (L <= R)。求ALL 至 ARR 这R - L + 1个数中,与X 进行异或运算(Xor),得到的最大值是多少?Input第1行:2个数N, Q中间用空格分隔,分别表示数组的长度及查询的数量(1 <= N <=
阅读全文
摘要:Kuro is currently playing an educational game about numbers. The game focuses on the greatest common divisor (GCD), the XOR value, and the sum of two
阅读全文
摘要:ps:感觉比昨天晚上的华师题目质量高一点,至少emmm,题面没有那么多bug。 下面忽略了水题,只给出我觉得有价值的几个题目的题解和代码: 【C:神山神石】: 题意: 每一天,Wells可以喂神山一个神石,使得神山的高度变为原高度乘上神石的能力值,或者使得所有的神石能力值+1。第 0 天时,所有神石
阅读全文
摘要:You are given a sequence A[1], A[2], ..., A[N]. (0 ≤ A[i] < 231, 1 ≤ N ≤ 12000). A query is defined as follows: Query(x,y) = Max { a[i] xor a[i+1] xor
阅读全文
摘要:In an edge-weighted tree, the xor-length of a path p is defined as the xor sum of the weights of edges on p: ⊕ is the xor operator. We say a path the
阅读全文
摘要:一:解决XOR常用的方法: 在vjudge上面输入关键词xor,然后按照顺序刷了一些题。 然后大概悟出了一些的的套路: 我是分界线 POJ 3764: The xor-longest 字典树求最大异或 POJ 3764: The xor-longest 字典树求最大异或 #include<cmath
阅读全文
摘要:Zeus 和 Prometheus 做了一个游戏,Prometheus 给 Zeus 一个集合,集合中包含了N个正整数,随后 Prometheus 将向 Zeus 发起M次询问,每次询问中包含一个正整数 S ,之后 Zeus 需要在集合当中找出一个正整数 K ,使得 K 与 S 的异或结果最大。Pr
阅读全文
摘要:You have two integers L and R, and you are required to find the max xor value of a and b where L <= a <= R and L <= b <= R Input Two integers in a lin
阅读全文
摘要:Bob has a favorite number k and ai of length n. Now he asks you to answer m queries. Each query is given by a pair li and ri and asks you to count the
阅读全文
摘要:Claris loves bitwise operations very much, especially XOR, because it has many beautiful features. He gets four positive integers a,b,c,da,b,c,d that
阅读全文
摘要:Alice bought a lot of pairs of socks yesterday. But when she went home, she found that she has lost one of them. Each sock has a name which contains e
阅读全文