Playing games

Subject:
https://ac.nowcoder.com/acm/contest/295/H

There are n numbers, choose as many numbers as possible so that the exclusive or sum is 0 00 .
1 ≤ n ≤ 500000, 0 ≤ a ≤ 1 500000 \ k \ The 500000.0 \ the a_i \ the 5000001n500000,0ai5 0 0 0 0 0
Idea: The
problem is equivalent to choosing as few numbers as possible so that the XOR sum is the XOR sum of all numbers.val valv a l . According to the linear basis idea, it can be deduced that the exclusive OR of the entire set can be no more than19 191 9 XOR set representation. So the answer does not exceed19 191 9 . So the answer can be dichotomy.
So how to judge themid midCan the number of m i d be XORed intoval valv a l , you can use the generating functionA = ∑ i = 0 500000 aixi A=\sum_{i=0}^{500000}a_ix^iA=i=0500000aixi a i = 1 a_i=1 ai=1 DisplayiiThe number i exists and is0 00 means not present,A k A^kAk means choosekkk , but here is the exclusive OR of the polynomial, useFWT FWTF W T , and calculateB = A k B=A^kB=Ak , you can directly calculateFWT (B) = FWT (A) k FWT(B)=FWT(A)^kFWT(B)=FWT(A)k , so just putAAA becomesFWT (A) FWT (A)F W T ( A ) , then countkkfor each bitk to the power, thenFWT (B) FWT (B)F W T ( B ) becomesBBB is fine, similar to point value notation.
Also note that this will select repetitions, so it is impossible to directly judge whether you can just selectmid midThe number of m i d , but the repeated XOR will cancel out, which is equivalent to the number selected is less thanmid midm i d , because it is a binary judgment, it is the second best to judge whether you can use less thanmid midThe number of m i d , then a functiona 0 = 1 a_0=1a0=1. Representatives may not choose.

Summary:
The convolution form of XOR is similar to the convolution obtained by addition, and the generating function can also be used.

Guess you like

Origin blog.csdn.net/qq_43520313/article/details/108894744