CF1119H.Triple

NOI/NOI+/CTSC

通过率:0%

时间限制:1.50s

内存限制:256MB

AC君温馨提醒

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

题目描述

You have received your birthday gifts — nn triples of integers! The ii-th of them is {ai,bi,ci}\lbrace a_{i}, b_{i}, c_{i} \rbrace. All numbers are greater than or equal to 00, and strictly smaller than 2k2^{k}, where kk is a fixed integer.

One day, you felt tired playing with triples. So you came up with three new integers xx, yy, zz, and then formed nn arrays. The ii-th array consists of aia_i repeated xx times, bib_i repeated yy times and cic_i repeated zz times. Thus, each array has length (x+y+z)(x + y + z).

You want to choose exactly one integer from each array such that the XOR (bitwise exclusive or) of them is equal to tt. Output the number of ways to choose the numbers for each tt between 00 and 2k−12^{k} - 1, inclusive, modulo 998244353998244353.

你收到了生日礼物——nn 组三元整数!其中第 ii 组为 {ai,bi,ci}\lbrace a_{i}, b_{i}, c_{i} \rbrace。所有数字均大于等于 00,且严格小于 2k2^{k},其中 kk 是一个给定的整数。

某天,你玩三元组玩累了,于是构造了三个新的整数 xx、yy、zz,并据此生成了 nn 个数组。第 ii 个数组由 aia_i 重复 xx 次、bib_i 重复 yy 次、cic_i 重复 zz 次构成。因此,每个数组的长度均为 (x+y+z)(x + y + z)。

你希望从每个数组中恰好选择一个整数,使得它们的异或(按位异或)结果恰好等于 tt。请对每个满足 0≤t≤2k−10 \le t \le 2^{k} - 1 的 tt,输出满足条件的选择方案数(模 998244353998244353)。

输入格式

The first line contains two integers nn and kk (1≤n≤1051 \leq n \leq 10^{5}, 1≤k≤171 \leq k \leq 17) — the number of arrays and the binary length of all numbers.

The second line contains three integers xx, yy, zz (0≤x,y,z≤1090 \leq x,y,z \leq 10^{9}) — the integers you chose.

Then nn lines follow. The ii-th of them contains three integers aia_{i}, bib_{i} and cic_{i} (0≤ai,bi,ci≤2k−10 \leq a_{i} , b_{i} , c_{i} \leq 2^{k} - 1) — the integers forming the ii-th array.

第一行包含两个整数 nn 和 kk(1≤n≤1051 \leq n \leq 10^{5},1≤k≤171 \leq k \leq 17)—— 分别表示数组的个数以及所有数字的二进制长度。

第二行包含三个整数 xx、yy、zz(0≤x,y,z≤1090 \leq x,y,z \leq 10^{9})—— 表示你所选定的整数。

接下来是 nn 行。其中第 ii 行包含三个整数 aia_{i}、bib_{i} 和 cic_{i}(0≤ai,bi,ci≤2k−10 \leq a_{i} , b_{i} , c_{i} \leq 2^{k} - 1)—— 构成第 ii 个数组的整数。

输出格式

Print a single line containing 2k2^{k} integers. The ii-th of them should be the number of ways to choose exactly one integer from each array so that their XOR is equal to t=i−1t = i-1 modulo 998244353998244353.

输出一行,包含 2k2^{k} 个整数。其中第 ii 个整数表示:从每个数组中恰好选择一个整数,使得它们的异或值等于 t=i−1t = i-1 的方案数(对 998244353998244353 取模)。

输入输出样例

  • 输入#1

    1 1
    1 2 3
    1 0 1

    输出#1

    2 4
  • 输入#2

    2 2
    1 2 1
    0 1 2
    1 2 3

    输出#2

    4 2 4 6
  • 输入#3

    4 3
    1 2 3
    1 3 7
    0 2 5
    1 0 6
    3 3 2

    输出#3

    198 198 126 126 126 126 198 198

说明/提示

In the first example, the array we formed is (1,0,0,1,1,1)(1, 0, 0, 1, 1, 1), we have two choices to get 00 as the XOR and four choices to get 11.

In the second example, two arrays are (0,1,1,2)(0, 1, 1, 2) and (1,2,2,3)(1, 2, 2, 3). There are sixteen (4⋅4)(4 \cdot 4) choices in total, 44 of them (1⊕11 \oplus 1 and 2⊕22 \oplus 2, two options for each) give 00, 22 of them (0⊕10 \oplus 1 and 2⊕32 \oplus 3) give 11, 44 of them (0⊕20 \oplus 2 and 1⊕31 \oplus 3, two options for each) give 22, and finally 66 of them (0⊕30 \oplus 3, 2⊕12 \oplus 1 and four options for 1⊕21 \oplus 2) give 33.

在第一个例子中,我们构造的数组为 (1,0,0,1,1,1)(1, 0, 0, 1, 1, 1),其中共有两种选择使得异或结果为 00,四种选择使得异或结果为 11。

在第二个例子中,两个数组分别为 (0,1,1,2)(0, 1, 1, 2) 和 (1,2,2,3)(1, 2, 2, 3)。总共有十六种(4⋅44 \cdot 4)选择:其中 44 种(1⊕11 \oplus 1 和 2⊕22 \oplus 2,每种各有两种选项)得到 00;22 种(0⊕10 \oplus 1 和 2⊕32 \oplus 3)得到 11;44 种(0⊕20 \oplus 2 和 1⊕31 \oplus 3,每种各有两种选项)得到 22;最后 66 种(0⊕30 \oplus 3、2⊕12 \oplus 1 以及 1⊕21 \oplus 2 的四种选项)得到 33。

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

首页