传送门 01trie板子题. 给出两个数列,允许把第二个数列重新排列. 求使得两个数列每个位置对应的数的异或值和成为最小值的每个位置的异或和. 把第二个数列插入到01trie里面然后对于第一个数列中的数挨个询问最小异或和即可. 代码: #include<bits/stdc++.h> #define ri register int using namespace std; const int N=3e5+5,P=30; int n,son[N*30][2],siz[N*30],a[N],tot=…
Codeforces 979 D. Kuro and GCD and XOR and SUM 题目大意:有两种操作:①给一个数v,加入数组a中②给出三个数x,k,s:从当前数组a中找出一个数u满足 u与x的gcd可以被k整除,u不大于s-x,且与x的异或和最大. 思路:之前没有碰到过异或和最值的问题,所以是懵逼的.学习了01字典树后把这题补出来. 碰到操作①就上树,上树过程中注意不断维护每个节点往后路径中的最小值(具体见代码细节): 碰到操作②,如果k==1,那么从树上找数的同时注意限制条件最小…
As you might remember from the previous round, Vova is currently playing a strategic game known as Rage of Empires. Vova managed to build a large army, but forgot about the main person in the army - the commander. So he tries to hire a commander, and…