CF1616H.Keep XOR Low

NOI/NOI+/CTSC

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

You are given an array a1,a2,…,ana_1, a_2, \ldots, a_n and an integer xx.

Find the number of non-empty subsets of indices of this array 1≤b1<b2<…<bk≤n1 \leq b_1 \lt b_2 \lt \ldots \lt b_k \leq n, such that for all pairs (i,j)(i, j) where 1≤i<j≤k1 \leq i \lt j \leq k, the inequality abi⊕abj≤xa_{b_i} \oplus a_{b_j} \leq x is held. Here, ⊕\oplus denotes the bitwise XOR operation. As the answer may be very large, output it modulo 998 244 353998\,244\,353.

给你一个数组 a1,a2,…,ana_1, a_2, \ldots, a_n 和一个整数 xx。

请找出该数组中满足如下条件的非空下标子集 1≤b1<b2<…<bk≤n1 \leq b_1 \lt b_2 \lt \ldots \lt b_k \leq n 的个数:对所有满足 1≤i<j≤k1 \leq i \lt j \leq k 的数对 (i,j)(i, j),均有不等式 abi⊕abj≤xa_{b_i} \oplus a_{b_j} \leq x 成立。其中,⊕\oplus 表示按位异或运算。由于答案可能非常大,请将结果对 998 244 353998\,244\,353 取模后输出。

输入格式

The first line of the input contains two integers nn and xx (1≤n≤150 0001 \leq n \leq 150\,000, 0≤x<2300 \leq x \lt 2^{30}). Here, nn is the size of the array.

The next line contains nn integers a1,a2,…,ana_1, a_2, \ldots, a_n (0≤ai<2300 \leq a_i \lt 2^{30}): the array itself.

输入的第一行包含两个整数 nn 和 xx(1≤n≤150 0001 \leq n \leq 150\,000,0≤x<2300 \leq x \lt 2^{30})。其中,nn 表示数组的大小。

第二行包含 nn 个整数 a1,a2,…,ana_1, a_2, \ldots, a_n(0≤ai<2300 \leq a_i \lt 2^{30}):即该数组本身。

输出格式

Print one integer: the number of non-empty subsets such that the bitwise XOR of every pair of elements is at most xx, modulo 998 244 353998\,244\,353.

输出一个整数:满足“任意两个元素的按位异或值不超过 xx”的非空子集的个数,对 998 244 353998\,244\,353 取模。

输入输出样例

  • 输入#1

    4 2
    0 1 2 3

    输出#1

    8
  • 输入#2

    3 6
    4 2 2

    输出#2

    7
  • 输入#3

    4 0
    1 1 2 2

    输出#3

    6

输入解题思路,AI测评打分。不知道怎么写?

首页