F. [R6F]异或问题

    Type: Default 2000ms 512MiB

[R6F]异或问题

You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.

时空限制

2S/512M

题目描述

给定整数 XX 和一个长度为 nn 的整数数组 AA,对于 1n1\sim n 的每个 ii 求有多少个 jj 同时满足以下三个条件:

  • iji\leq j

  • AiAj>XA_i\oplus A_j> X

  • popcount(Ai)popcount(Aj)\text{popcount}(A_i)\leq \text{popcount}(A_j)

这里的 \oplus 表示按位异或运算。

popcount(V)\text{popcount}(V) 表示求 VV 在二进制下 11 的数量,例如:popcount(7)=3\text{popcount}(7)=3popcount(16)=1\text{popcount}(16)=1popcount(0)=0\text{popcount}(0)=0

格式

输入格式

第一行包含两个整数 nnXX,分别表示数组 AA 的长度和 AiAjA_i\oplus A_j 需要大于的值。

第二行包含 nn 个整数 AiA_i

输出格式

输出一行包含 nn 个整数,第 ii 个整数表示有多少个 jj 同时满足三个条件。

样例

样例输入 #1

6 4
3 4 7 6 8 3

样例输出 #1

1 2 0 1 1 0

样例解释 #1

对于 i=1i=1popcount(A1)=2\text{popcount}(A_1)=2,有一个 jj 满足条件:A1A4=5A_1\oplus A_4=5popcount(A4)=2\text{popcount}(A_4)=2

对于 i=2i=2popcount(A2)=1\text{popcount}(A_2)=1,有两个 jj 满足条件:A2A5=12A_2\oplus A_5=12popcount(A5)=1\text{popcount}(A_5)=1A2A6=7A_2\oplus A_6=7popcount(A6)=2\text{popcount}(A_6)=2

对于 i=3i=3popcount(A3)=3\text{popcount}(A_3)=3,有零个 jj 满足条件。

对于 i=4i=4popcount(A4)=2\text{popcount}(A_4)=2,有一个 jj 满足条件:A4A6=5A_4\oplus A_6=5popcount(A6)=2\text{popcount}(A_6)=2

对于 i=5i=5popcount(A5)=1\text{popcount}(A_5)=1,有一个 jj 满足条件:A5A6=11A_5\oplus A_6=11popcount(A6)=2\text{popcount}(A_6)=2

对于 i=6i=6popcount(A6)=2\text{popcount}(A_6)=2,有零个 jj 满足条件。

数据规模

对于 20%20\% 的数据,n1000n\leq 1000

另有 30%30\% 的数据,X,Ai1000X,A_i\leq 1000

对于 100%100\% 的数据,1n2×1051\leq n\leq 2\times 10^50X,Ai1090\leq X,A_i\leq 10^9

代码源挑战赛 Round 6

Not Attended
Status
Done
Rule
DMY
Problem
6
Start at
2025-4-4 20:00
End at
2025-4-4 21:30
Duration
1.5 hour(s)
Host
Partic.
564