QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#212060 | #5205. Game of Questions | 275307894a | TL | 578ms | 175932kb | C++14 | 1.8kb | 2023-10-13 07:01:21 | 2023-10-13 07:01:22 |
Judging History
answer
#include<bits/stdc++.h>
#define Gc() getchar()
#define Me(x,y) memset(x,y,sizeof(x))
#define Mc(x,y) memcpy(x,y,sizeof(x))
#define d(x,y) ((m)*(x-1)+(y))
#define R(n) (rnd()%(n)+1)
#define Pc(x) putchar(x)
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second
using namespace std;using ll=long long;using db=double;using lb=long db;using ui=unsigned;using ull=unsigned long long;using pii=pair<int,int>;using LL=__int128;
const int N=(1<<17)+5,M=43046721+5,K=600+5,mod=998244353,Mod=mod-1;const db eps=1e-6;const int INF=1e9+7;mt19937 rnd(263082);
int n,m,k,f[N],g[N],ff[N],gg[N];lb dp[N];
char s[N];
void FWT(int *A){
int i,j,h;
for(i=2;i<=k;i<<=1) {
for(j=0;j<k;j+=i) {
for(h=j;h<j+i/2;h++) A[h]+=A[h+i/2];
}
}
}
int p[M],Po[N],To[N];
int main(){
int i,j,h;scanf("%d%d",&n,&m);k=1<<m-1;
int tot=k-1;
for(i=1;i<=n;i++){
scanf("%s",s+1);
int z=0;for(j=2;j<=m;j++) z=z<<1|(s[j]=='1');
if(s[1]=='0') g[(k-1)^z]++,gg[(k-1)^z]++;
else f[z]++,tot&=z,ff[z]++;
z=0;for(j=2;j<=m;j++) z=z*3+(s[j]=='1'?2:1);if(s[1]=='1') p[z]++;
}
for(Po[0]=i=1;i<=m;i++) Po[i]=Po[i-1]*3;
for(i=0;i<m-1;i++){
for(h=0;h<Po[m-1];h+=Po[i]) if(h/Po[i]%3==0) for(j=h;j<h+Po[i];j++) p[j]+=p[j+Po[i]]+p[j+Po[i]*2];
}
FWT(f);FWT(g);
// inv[1]=1;for(i=2;i<=n;i++) inv[i]=(mod-inv[mod%i])*(mod/i)%mod;
dp[k-1]=1;
for(i=0;i<k;i++){
for(j=0;j<m-1;j++) if(i>>j&1) To[i]+=Po[j];
}
cerr<<f[3]<<'\n';
for(i=k-2;~i;i--){
for(j=(k-1)^i;j;j=(j-1)&((k-1)^i)) {
dp[i]+=dp[i^j]*p[To[i]*2+To[j]]/(n-(f[i^j]+g[i^j]));
// cerr<<p[To[i]*2+To[j]]<<' ';
}
// cerr<<i<<' '<<dp[i]<<'\n';
}
printf("%.11Lf\n",(n-g[tot]-f[tot]?0.0:dp[tot]));
cerr<<clock()*1.0/CLOCKS_PER_SEC<<'\n';
}
//0 1 0 1 0 1 0 1 0 0 1 1 0 0 0 1 0 1 0
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 2ms
memory: 10140kb
input:
1 5 11010
output:
1.00000000000
result:
ok found '1.000000000', expected '1.000000000', error '0.000000000'
Test #2:
score: 0
Accepted
time: 1ms
memory: 10228kb
input:
3 3 011 101 110
output:
0.33333333333
result:
ok found '0.333333333', expected '0.333333333', error '0.000000000'
Test #3:
score: 0
Accepted
time: 1ms
memory: 10228kb
input:
6 4 1011 0110 1111 0110 0000 1101
output:
0.16666666667
result:
ok found '0.166666667', expected '0.166666667', error '0.000000000'
Test #4:
score: 0
Accepted
time: 1ms
memory: 10224kb
input:
1 2 00
output:
1.00000000000
result:
ok found '1.000000000', expected '1.000000000', error '0.000000000'
Test #5:
score: 0
Accepted
time: 1ms
memory: 10156kb
input:
1 2 11
output:
1.00000000000
result:
ok found '1.000000000', expected '1.000000000', error '0.000000000'
Test #6:
score: 0
Accepted
time: 1ms
memory: 8168kb
input:
2 5 10011 01111
output:
0.00000000000
result:
ok found '0.000000000', expected '0.000000000', error '-0.000000000'
Test #7:
score: 0
Accepted
time: 0ms
memory: 10100kb
input:
5 2 11 11 11 01 10
output:
0.50000000000
result:
ok found '0.500000000', expected '0.500000000', error '0.000000000'
Test #8:
score: 0
Accepted
time: 1ms
memory: 10208kb
input:
10 10 0110100110 1100101110 1011100110 0011001011 1100101000 0010001001 1101100111 0000001101 1100000011 1100111100
output:
0.10300925926
result:
ok found '0.103009259', expected '0.103009259', error '0.000000000'
Test #9:
score: 0
Accepted
time: 1ms
memory: 10224kb
input:
100 10 1000101100 0011110101 1101010000 1011101011 0001000111 1110111101 1010001110 0000110111 1101110001 0000110010 1001111111 1010100001 1110000111 1111000111 1110101010 1101000101 1000010110 0110110100 0100001000 1000001001 0111100010 0100011110 0100111111 1000110000 0111010011 0110000100 1001101...
output:
0.11879676721
result:
ok found '0.118796767', expected '0.118796767', error '0.000000000'
Test #10:
score: 0
Accepted
time: 3ms
memory: 12288kb
input:
10000 13 0101111101110 1010110100101 1000011001110 0110001100100 1011011000111 0111111101111 0100111101111 1110001011100 0100011000110 0000110010101 0101100000111 0010010101001 1010001001100 0010101001100 1001011000010 0001101100001 0100111000011 1001100110111 0001001001111 1000000010101 00111000111...
output:
0.07474853406
result:
ok found '0.074748534', expected '0.074748534', error '0.000000000'
Test #11:
score: 0
Accepted
time: 50ms
memory: 28768kb
input:
100000 15 010101111010100 111100100000101 110010011010010 111000011011011 010101001100001 110111000011110 000011010000101 100100001001111 000101111001000 011101001000110 100011011110001 000111101100110 101110100000111 001000011011100 010011110010110 101111111100011 100110100000110 011101110100110 11...
output:
0.06573476633
result:
ok found '0.065734766', expected '0.065734766', error '0.000000000'
Test #12:
score: 0
Accepted
time: 170ms
memory: 65528kb
input:
200000 16 0001110111010101 1001011100001110 0001110100100111 0101000101000001 0010010011001011 0101111000000011 1011010000110001 1100111100101000 1110110100000100 0000010010110100 0101101101111100 0111001111001100 1000101011101010 0110100011001000 1010100111011100 0000101101010001 0010001011000000 0...
output:
0.06272740537
result:
ok found '0.062727405', expected '0.062727405', error '0.000000000'
Test #13:
score: 0
Accepted
time: 522ms
memory: 175932kb
input:
200000 17 11000001110100100 10101000100010101 00011000101010000 01111000011000100 11000111100001101 10101011010111000 00011011011001011 10110100010000110 11001111101010001 01010000110011100 01001011100111000 00011100110100010 11000100001100011 10011001100001111 11110110001001110 10001100000100110 11...
output:
0.05857261642
result:
ok found '0.058572616', expected '0.058572616', error '0.000000000'
Test #14:
score: 0
Accepted
time: 6ms
memory: 10144kb
input:
200000 2 10 11 11 01 01 11 00 01 10 00 10 00 11 00 00 11 00 01 01 10 11 01 11 10 11 11 01 01 10 10 00 00 01 11 10 01 10 10 10 10 11 00 00 10 11 01 10 11 10 10 00 10 01 11 00 11 01 01 10 11 01 01 01 00 11 10 10 10 11 11 10 01 10 00 00 01 00 00 10 01 01 01 01 00 00 11 11 00 10 10 11 11 00 00 01 10 00 ...
output:
0.50094126129
result:
ok found '0.500941261', expected '0.500941261', error '0.000000000'
Test #15:
score: 0
Accepted
time: 578ms
memory: 175548kb
input:
1 17 01011010000010110
output:
0.00000000000
result:
ok found '0.000000000', expected '0.000000000', error '-0.000000000'
Test #16:
score: 0
Accepted
time: 3ms
memory: 8120kb
input:
200000 2 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ...
output:
1.00000000000
result:
ok found '1.000000000', expected '1.000000000', error '0.000000000'
Test #17:
score: -100
Time Limit Exceeded
input:
1 17 00000000000000000