# 【CF1119H】Triple

## 题解

$e,f,g,h$解方程解出来就好了，实现细节详见代码。

## 代码

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
using LL = long long;
const int Mod = 998244353, inv2 = (Mod + 1) >> 1;
int fpow(int x, LL y) {
int res = 1;
while (y) {
if (y & 1) res = 1ll * res * x % Mod;
x = 1ll * x * x % Mod;
y >>= 1;
}
return res;
}
const int MAX_N = 1 << 17 | 1;
int N, K, Limit;
void FWT(LL p[]) {
for (int i = 1; i < Limit; i <<= 1)
for (int j = 0; j < Limit; j += i << 1)
for (int k = 0; k < i; k++) {
LL x = p[j + k], y = p[i + j + k];
p[j + k] = x + y, p[i + j + k] = x - y;
}
}
void IFWT(LL p[]) {
for (int i = 1; i < Limit; i <<= 1)
for (int j = 0; j < Limit; j += i << 1)
for (int k = 0; k < i; k++) {
LL x = p[j + k] % Mod, y = p[i + j + k] % Mod;
p[j + k] = 1ll * (x + y) * inv2 % Mod, p[i + j + k] = 1ll * (x - y + Mod) * inv2 % Mod;
}
}

LL F[MAX_N], G[MAX_N], H[MAX_N], A[MAX_N];
int x, y, z;
int sum;
LL s1, s2, s3, s4;

int main () {
#ifndef ONLINE_JUDGE
freopen("cpp.in", "r", stdin);
#endif
scanf("%d %d %d %d %d", &N, &K, &x, &y, &z); Limit = 1 << K;
for (int i = 1; i <= N; i++) {
int a, b, c; scanf("%d %d %d", &a, &b, &c);
sum ^= a, ++F[a ^ b], ++G[a ^ c], ++H[b ^ c];
}
s1 = 1ll * x + y + z, s2 = 1ll * x + y - z, s3 = 1ll * x - y + z, s4 = 1ll * x - y - z;
s1 %= Mod, s2 %= Mod, s3 %= Mod, s4 %= Mod;
FWT(F), FWT(G), FWT(H);
for (int i = 0; i < Limit; i++) {
LL e = (N + F[i] + G[i] + H[i]) >> 2;
LL f = (N + F[i] - 2 * e) >> 1;
LL g = (N + G[i] - 2 * e) >> 1;
LL h = (N + H[i] - 2 * e) >> 1;
A[i] = 1ll * fpow(s1, e) * fpow(s2, f) % Mod * fpow(s3, g) % Mod * fpow(s4, h) % Mod;
}
IFWT(A);
for (int i = 0; i < Limit; i++) printf("%I64d ", (A[i ^ sum] + Mod) % Mod);
putchar('\n');
return 0;
}

posted @ 2020-07-14 00:00  heyujun  阅读(198)  评论(0编辑  收藏  举报