-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathE2.cpp
143 lines (127 loc) · 2.67 KB
/
E2.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
#include <bits/stdc++.h>
#define fi first
#define se second
#define db double
#define U unsigned
#define P std::pair<int,int>
#define LL long long
#define pb push_back
#define MP std::make_pair
#define all(x) x.begin(),x.end()
#define CLR(i,a) memset(i,a,sizeof(i))
#define FOR(i,a,b) for(int i = a;i <= b;++i)
#define ROF(i,a,b) for(int i = a;i >= b;--i)
#define DEBUG(x) std::cerr << #x << '=' << x << std::endl
const int MAXN = 53+5;
const int ha = 998244353;
const int inv2 = 499122177;
int n,m;
LL b[MAXN];
inline void insert(LL x){
ROF(i,m-1,0){
if((x>>i)&1){
if(b[i]) x ^= b[i];
else{b[i] = x;break;}
}
}
}
int sz;
inline void add(int &x,int y){
x += y;if(x >= ha) x -= ha;
}
namespace Subtask1{
std::vector<LL> v;
int ans[233];
inline void dfs(int step,LL now){
if(step == sz){
add(ans[__builtin_popcountll(now)],1);
return;
}
dfs(step+1,now);
dfs(step+1,now^v[step]);
}
inline void Solve(){
FOR(i,0,m-1) if(b[i]) v.pb(b[i]);
dfs(0,0);
int pw = 1;FOR(i,1,n-sz) pw = 2ll*pw%ha;
FOR(i,0,m) printf("%lld ",1ll*ans[i]*pw%ha);puts("");
exit(0);
}
}
inline int qpow(int a,int n=ha-2){
int res = 1;
while(n){
if(n & 1) res = 1ll*res*a%ha;
a = 1ll*a*a%ha;
n >>= 1;
}
return res;
}
int fac[MAXN],inv[MAXN];
inline void prework(){
fac[0] = 1;FOR(i,1,MAXN-1) fac[i] = 1ll*fac[i-1]*i%ha;
inv[MAXN-1] = qpow(fac[MAXN-1]);ROF(i,MAXN-2,0) inv[i] = 1ll*inv[i+1]*(i+1)%ha;
}
inline int C(int n,int m){
if(n < m) return 0;
if(n < 0 || m < 0) return 0;
return 1ll*fac[n]*inv[m]%ha*inv[n-m]%ha;
}
namespace Subtask2{
LL B[MAXN];
int f[666],ans[233];
std::vector<LL> v;
inline void dfs(int step,LL now){
if(step == m-sz){
f[__builtin_popcountll(now)]++;
return;
}
dfs(step+1,now);dfs(step+1,now^v[step]);
}
inline void Solve(){
FOR(i,0,m-1){
FOR(j,0,m-1){
B[j] |= ((b[i]>>j)&1)<<i;
}
}
FOR(i,0,m-1){
B[i] ^= (1ll<<i);
if((B[i]>>i)&1) v.pb(B[i]);
}
dfs(0,0);
FOR(c,0,m){
FOR(d,0,m){
int sm = 0;
FOR(i,0,d){
int gx = 1ll*C(d,i)*C(m-d,c-i)%ha;
if(i&1) gx = ha-gx;
add(sm,gx);
}
sm = 1ll*sm*f[d]%ha;
add(ans[c],sm);
}
ans[c] = 1ll*ans[c]*qpow(inv2,m-sz)%ha;
ans[c] = 1ll*ans[c]*qpow(2,n-sz)%ha;
printf("%d ",ans[c]);
}
puts("");exit(0);
}
}
int main(){
prework();
scanf("%d%d",&n,&m);
FOR(i,1,n){
LL x;scanf("%lld",&x);insert(x);
}
ROF(i,m-1,0){
if(b[i]){
FOR(j,i+1,m-1){
if((b[j]>>i)&1) b[j] ^= b[i];
}
}
}
FOR(i,0,m-1) if(b[i]) ++sz;
if(sz <= 26) Subtask1::Solve();
else Subtask2::Solve();
return 0;
}