Submission #66163552
Source Code Expand
#pragma GCC optimize("O3")
#include "bits/stdc++.h"
using namespace std;
#define all(x) x.begin(),x.end()
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << p.first << " " << p.second; }
template<typename T_container, typename T = typename enable_if<!is_same<T_container, string>::value, typename T_container::value_type>::type> ostream& operator<<(ostream &os, const T_container &v) { string sep; for (const T &x : v) os << sep << x, sep = " "; return os; }
#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#define ASSERT(...) 42
#endif
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pi;
const int oo = 1e9;
const long long MD = 998244353;
template<long long MOD=MD> struct mdint {
int d;
mdint () {d=0;}
mdint (long long _d) : d(_d%MOD){
if(d<0) d+=MOD;
};
friend mdint& operator+=(mdint& a, const mdint& o) {
a.d+=o.d; if(a.d>=MOD) a.d-=MOD;
return a;
}
friend mdint& operator-=(mdint& a, const mdint& o) {
a.d-=o.d; if(a.d<0) a.d+=MOD;
return a;
}
friend mdint& operator*=(mdint& a, const mdint& o) {
return a = mdint((ll)a.d*o.d);
}
mdint operator*(const mdint& o) const {
mdint res = *this;
res*=o;
return res;
}
mdint operator+(const mdint& o) const {
mdint res = *this;
res+=o;
return res;
}
mdint operator-(const mdint& o) const {
mdint res = *this;
res-=o;
return res;
}
mdint operator^(long long b) const {
mdint tmp = 1;
mdint power = *this;
while(b) {
if(b&1) {
tmp = tmp*power;
}
power = power*power;
b/=2;
}
return tmp;
}
friend mdint operator/=(mdint& a, const mdint& o) {
a *= (o^(MOD-2));
return a;
}
mdint operator/(const mdint& o) {
mdint res = *this;
res/=o;
return res;
}
auto operator<=>(const mdint& o) const { return d<=>o.d;}
friend istream& operator>>(istream& c, mdint& a) {return c >> a.d;}
friend ostream& operator<<(ostream& c, const mdint& a) {return c << a.d;}
};
using mint = mdint<MD>;
void fft(auto a, auto b) {
int n = b-a;
for(int j=0;(1<<j)<n;++j) for(int i=0;i<n;++i) if(1<<j & i) {
a[i]+=a[i^(1<<j)];
}
}
void ifft(auto a,auto b) {
int n = b-a;
for(int j=0;(1<<j)<n;++j) for(int i=0;i<n;++i) if(1<<j & i) {
a[i]-=a[i^(1<<j)];
}
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n,m; cin >> n >> m;
const int K = 1<<n;
vi a(K);
for(int i=0;i<m;++i) {
int x; cin >> x;
a[x]++;
}
fft(all(a));
vector<mint> dp(K+1);
// want to keep prefix sum updated.
// when a bit disappears:
//
dp[0]=1;
vector<mint> cur(K);
auto solve = [&](auto&& self, int l, int r, auto L, auto R) -> void {
if(r-l==1) {
dp[l+1] += dp[l] * L[0];
return;
}
int mid = (l+r)/2;
int len = r-l;
self(self,l,mid,L, L+len/2);
// transition!
{
copy(dp.begin()+l,dp.begin()+mid,cur.begin());
fft(cur.begin(),cur.begin()+len/2);
for(int i=0;i<len/2;++i) cur[i]*=(L[i+len/2]-L[i]);
ifft(cur.begin(),cur.begin()+len/2);
for(int i=0;i<len/2;++i) {
dp[mid+i+1]+=cur[i];
}
}
self(self,mid,r,L+len/2,R);
};
solve(solve,0,K,all(a));
cout << dp[K] << '\n';
}
Submission Info
| Submission Time |
|
| Task |
E - Monotone OR |
| User |
Jeroenodb |
| Language |
C++ 23 (gcc 12.2) |
| Score |
900 |
| Code Size |
3770 Byte |
| Status |
AC |
| Exec Time |
4441 ms |
| Memory |
199744 KiB |
Judge Result
| Set Name |
Sample |
All |
| Score / Max Score |
0 / 0 |
900 / 900 |
| Status |
|
|
| Set Name |
Test Cases |
| Sample |
example_00.txt, example_01.txt, example_02.txt |
| All |
example_00.txt, example_01.txt, example_02.txt, test_00.txt, test_01.txt, test_02.txt, test_03.txt, test_04.txt, test_05.txt, test_06.txt, test_07.txt, test_08.txt, test_09.txt, test_10.txt, test_11.txt, test_12.txt, test_13.txt, test_14.txt, test_15.txt, test_16.txt, test_17.txt, test_18.txt |
| Case Name |
Status |
Exec Time |
Memory |
| example_00.txt |
AC |
1 ms |
3384 KiB |
| example_01.txt |
AC |
1 ms |
3588 KiB |
| example_02.txt |
AC |
4413 ms |
199680 KiB |
| test_00.txt |
AC |
1 ms |
3440 KiB |
| test_01.txt |
AC |
1 ms |
3408 KiB |
| test_02.txt |
AC |
1 ms |
3492 KiB |
| test_03.txt |
AC |
1 ms |
3424 KiB |
| test_04.txt |
AC |
1 ms |
3420 KiB |
| test_05.txt |
AC |
2049 ms |
101260 KiB |
| test_06.txt |
AC |
1 ms |
3416 KiB |
| test_07.txt |
AC |
1 ms |
3464 KiB |
| test_08.txt |
AC |
10 ms |
3780 KiB |
| test_09.txt |
AC |
49 ms |
6324 KiB |
| test_10.txt |
AC |
96 ms |
9120 KiB |
| test_11.txt |
AC |
203 ms |
15392 KiB |
| test_12.txt |
AC |
206 ms |
15324 KiB |
| test_13.txt |
AC |
4432 ms |
199684 KiB |
| test_14.txt |
AC |
4413 ms |
199672 KiB |
| test_15.txt |
AC |
4426 ms |
199672 KiB |
| test_16.txt |
AC |
4441 ms |
199732 KiB |
| test_17.txt |
AC |
4437 ms |
199664 KiB |
| test_18.txt |
AC |
4440 ms |
199744 KiB |