题目大意: 定义mex数为数组中第一个没有出现的非负整数.有m个操作,每个操作有一个x,将数组中所有的元素都异或x,然后询问当前的mex Input First line contains two integer numbers n and m (1 ≤ n, m ≤ 3·105) — number of elements in array and number of queries. Next line contains n integer numbers ai (0 ≤ ai ≤ 3·105…
给一个序列,每次操作对这个序列中的所有数异或一个x,问每次操作完以后整个序列的mex值. 做法是去重后构建01字典树,异或x就是对root加一个x的lazy标志,每次pushDown时如果lazy的这一位是1,则交换左右儿子.找mex的话只要每次往左走,如果左子树是满的,则往右走,并且加上左边相应造成的贡献.具体见代码: #include <bits/stdc++.h> using namespace std; ; typedef long long ll; int n, m; struct…
D. Vitya and Strange Lesson 题意 数列里有n个数,m次操作,每次给x,让n个数都异或上x.并输出数列的mex值. 题解 01字典树保存每个节点下面有几个数,然后当前总异或的是sw,则sw为1的位的节点左右孩子交换(不用真的交换).左孩子的值小于左边总节点数则mex在左子树,否则在右子树. 代码 const int N=531000;//3e5<2^19<N int sw=0; struct Trie{ int ch[N*20][2]; int cnt[N*20];…
题意: Today at the lesson Vitya learned a very interesting function - mex. Mex of a sequence of numbers is the minimum non-negative number that is not present in the sequence as element. For example, mex([4, 33, 0, 1, 1, 5]) = 2 and mex([1, 2, 3]) = 0.…
Today at the lesson Vitya learned a very interesting function - mex. Mex of a sequence of numbers is the minimum non-negative number that is not present in the sequence as element. For example, mex([4, 33, 0, 1, 1, 5]) = 2 and mex([1, 2, 3]) = 0. Vit…