QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#748277 | #2600. Mismatch | World_Creater | TL | 9ms | 13892kb | C++17 | 1.2kb | 2024-11-14 19:53:33 | 2024-11-14 19:53:33 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int mod=998244353;
int n,a[1000005],f[1000005],g[1000005],h[1000005],ad=(1<<29)-1,Or;
int fac[1000005],inv[1000005];
int qpow(int a,int b)
{
if(b==0) return 1;
int g=qpow(a,b/2);
g=1ll*g*g%mod;
if(b&1) g=1ll*g*a%mod;
return g;
}
int C(int n,int m)
{
return 1ll*fac[n]*inv[m]%mod*inv[n-m]%mod;
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin>>n;
for(int i=1;i<=n;i++)
{
cin>>a[i];
ad&=a[i];
Or|=a[i];
f[a[i]]++;
}
fac[0]=inv[0]=1;
for(int i=1;i<=n;i++)
{
fac[i]=1ll*fac[i-1]*i%mod;
inv[i]=qpow(fac[i],mod-2)%mod;
}
if(ad!=0)
{
for(int i=1;i<=n;i++)
{
cout<<0<<" ";
}
return 0;
}
for(int i=0;i<19;i++)
{
for(int j=0;j<(1<<19);j++)
{
if(!(j>>i&1)) f[j]+=f[j^(1<<i)];
}
}
for(int i=0;i<(1<<19);i++)
{
if((Or&i)!=i) continue ;
int ni=i;
if(__builtin_parity(i)) g[n-f[ni]]--;
else g[n-f[ni]]++;
}
int w=1;
for(int i=1;i<=n;i++) if(g[i]<0) g[i]+=mod;
for(int i=0;i<=n;i++)
{
for(int j=0;j<=i;j++)
{
h[i]+=1ll*g[j]*C(n-j,i-j)%mod;
if(h[i]>=mod) h[i]-=mod;
}
}
for(int i=n-1;i>=0;i--) cout<<h[i]<<" ";
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 9ms
memory: 12416kb
input:
3 0 1 2
output:
1 3 1
result:
ok 3 number(s): "1 3 1"
Test #2:
score: 0
Accepted
time: 4ms
memory: 12780kb
input:
6 1 2 2 7 6 7
output:
0 3 9 10 5 1
result:
ok 6 numbers
Test #3:
score: 0
Accepted
time: 9ms
memory: 13328kb
input:
1 0
output:
1
result:
ok 1 number(s): "1"
Test #4:
score: 0
Accepted
time: 0ms
memory: 11836kb
input:
1 524287
output:
0
result:
ok 1 number(s): "0"
Test #5:
score: 0
Accepted
time: 8ms
memory: 11796kb
input:
2 0 0
output:
2 1
result:
ok 2 number(s): "2 1"
Test #6:
score: 0
Accepted
time: 4ms
memory: 11864kb
input:
2 2 262144
output:
0 1
result:
ok 2 number(s): "0 1"
Test #7:
score: 0
Accepted
time: 1ms
memory: 11832kb
input:
3 5 6 7
output:
0 0 0
result:
ok 3 number(s): "0 0 0"
Test #8:
score: 0
Accepted
time: 0ms
memory: 11844kb
input:
8 262136 262136 262136 262136 262136 262136 262136 262136
output:
0 0 0 0 0 0 0 0
result:
ok 8 numbers
Test #9:
score: 0
Accepted
time: 8ms
memory: 12520kb
input:
9 0 0 0 0 0 0 0 0 0
output:
9 36 84 126 126 84 36 9 1
result:
ok 9 numbers
Test #10:
score: 0
Accepted
time: 9ms
memory: 13892kb
input:
16 7 4 5 6 8 9 0 1 2 3 15 13 11 10 12 14
output:
1 40 360 1546 4144 7896 11408 12866 11440 8008 4368 1820 560 120 16 1
result:
ok 16 numbers
Test #11:
score: -100
Time Limit Exceeded
input:
524288 323049 327819 57429 412259 374361 54485 317667 114566 430606 273922 384418 433429 444663 353620 383084 13069 231609 484186 231139 469585 32430 456221 209359 347360 82941 508142 280704 425269 12267 364319 383903 132816 81258 114782 82902 281651 254335 83584 243303 245998 461366 78417 160748 16...