QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#722938#6970. 地震后的幻想乡TheZone100 ✓9ms4348kbC++201.7kb2024-11-07 20:40:482024-11-07 20:40:50

Judging History

你现在查看的是最新测评结果

  • [2024-11-07 20:40:50]
  • 评测
  • 测评结果:100
  • 用时:9ms
  • 内存:4348kb
  • [2024-11-07 20:40:48]
  • 提交

answer

#include<bits/stdc++.h>
#define rep(i,k,n) for(int i=k;i<=n;i++)
#define PB push_back
using namespace std;
const int N=13;
typedef long long ll;
typedef __float128 ld;
typedef vector<ll> ploy;
ploy operator + (const ploy& a,const ploy& b){
    ploy c(max(a.size(),b.size()),0);
    int sz_a=a.size()-1,sz_b=b.size()-1;
    rep(i,0,sz_a)c[i]+=a[i];
    rep(i,0,sz_b)c[i]+=b[i];
    return c;
}
ploy operator - (const ploy& a,const ploy& b){
    ploy c(max(a.size(),b.size()),0);
    int sz_a=a.size()-1,sz_b=b.size()-1;
    rep(i,0,sz_a)c[i]+=a[i];
    rep(i,0,sz_b)c[i]-=b[i];
    return c;
}
ploy operator * (const ploy& a,const ploy& b){
    ploy c(a.size()+b.size(),0);
    int sz_a=a.size()-1,sz_b=b.size()-1;
    rep(i,0,sz_a)rep(j,0,sz_b)c[i+j]+=a[i]*b[j]; 
    return c;
}
ld jifen_1(const ploy& a){
    ld res=0.0;
    int sz_a=a.size()-1;
    rep(i,0,sz_a)res+=(ld)a[i]/(i+1);
    return res; 
}
ploy f[1<<N],pow_1_x[N*N],g(1,1);
int a[N],n,m,cnt[1<<N],S;
void init(){
    rep(i,1,S)cnt[i]=cnt[i-(i&-i)]+1;
    pow_1_x[0].PB(1);
    pow_1_x[1].PB(1);pow_1_x[1].PB(-1);
    rep(i,2,m)
        pow_1_x[i]=pow_1_x[i-1] * pow_1_x[1]; 
}
int main(){
    scanf("%d%d",&n,&m);S=(1<<n)-1;
    int x,y;
    rep(i,1,m){
        scanf("%d%d",&x,&y);
        a[x]|=(1<<(y-1));
        a[y]|=(1<<(x-1));
    }init();
    rep(s,1,S){
        new (&f[s])ploy(1,1);
        int who=s&-s;
        for(int j=s^who;j;j=(j-1)&(s^who)){
            int i=s^j,edge=0;
            rep(k,1,n)if((i>>(k-1))&1)edge+=cnt[a[k]&j];
            f[s]=f[s] - f[i]*pow_1_x[edge];
        }
    }g=g - f[S];
    double ans=jifen_1(g);
    printf("%.6lf",ans);
}

詳細信息


Pretests


Final Tests

Test #1:

score: 5
Accepted
time: 0ms
memory: 4032kb

input:

2 1
2 1

output:

0.500000

result:

ok single line: '0.500000'

Test #2:

score: 5
Accepted
time: 0ms
memory: 3904kb

input:

3 2
2 1
3 2

output:

0.666667

result:

ok single line: '0.666667'

Test #3:

score: 5
Accepted
time: 0ms
memory: 3736kb

input:

3 3
2 1
3 1
3 2

output:

0.500000

result:

ok single line: '0.500000'

Test #4:

score: 5
Accepted
time: 4ms
memory: 3968kb

input:

10 10
2 1
4 1
4 3
6 2
7 3
7 4
9 3
9 5
9 8
10 5

output:

0.881818

result:

ok single line: '0.881818'

Test #5:

score: 5
Accepted
time: 4ms
memory: 3984kb

input:

10 10
2 1
5 2
5 4
6 1
7 3
7 5
8 3
8 5
9 7
10 5

output:

0.872727

result:

ok single line: '0.872727'

Test #6:

score: 5
Accepted
time: 2ms
memory: 4040kb

input:

10 10
6 5
7 2
8 1
8 4
8 6
9 1
9 3
9 5
10 6
10 7

output:

0.863636

result:

ok single line: '0.863636'

Test #7:

score: 5
Accepted
time: 9ms
memory: 4348kb

input:

10 45
2 1
3 1
3 2
4 1
4 2
4 3
5 1
5 2
5 3
5 4
6 1
6 2
6 3
6 4
6 5
7 1
7 2
7 3
7 4
7 5
7 6
8 1
8 2
8 3
8 4
8 5
8 6
8 7
9 1
9 2
9 3
9 4
9 5
9 6
9 7
9 8
10 1
10 2
10 3
10 4
10 5
10 6
10 7
10 8
10 9

output:

0.274864

result:

ok single line: '0.274864'

Test #8:

score: 5
Accepted
time: 3ms
memory: 3904kb

input:

9 36
2 1
3 1
3 2
4 1
4 2
4 3
5 1
5 2
5 3
5 4
6 1
6 2
6 3
6 4
6 5
7 1
7 2
7 3
7 4
7 5
7 6
8 1
8 2
8 3
8 4
8 5
8 6
8 7
9 1
9 2
9 3
9 4
9 5
9 6
9 7
9 8

output:

0.294173

result:

ok single line: '0.294173'

Test #9:

score: 5
Accepted
time: 0ms
memory: 4068kb

input:

5 7
2 1
3 1
4 2
4 3
5 1
5 2
5 4

output:

0.545238

result:

ok single line: '0.545238'

Test #10:

score: 5
Accepted
time: 0ms
memory: 4068kb

input:

5 7
3 2
4 1
4 2
4 3
5 1
5 3
5 4

output:

0.561905

result:

ok single line: '0.561905'

Test #11:

score: 5
Accepted
time: 0ms
memory: 3808kb

input:

5 8
3 1
4 1
4 2
4 3
5 1
5 2
5 3
5 4

output:

0.511905

result:

ok single line: '0.511905'

Test #12:

score: 5
Accepted
time: 0ms
memory: 4072kb

input:

5 8
3 1
3 2
4 1
4 2
5 1
5 2
5 3
5 4

output:

0.492063

result:

ok single line: '0.492063'

Test #13:

score: 5
Accepted
time: 1ms
memory: 3816kb

input:

8 15
3 1
4 1
4 2
4 3
5 1
5 2
6 2
6 3
7 1
7 4
8 1
8 3
8 4
8 6
8 7

output:

0.558508

result:

ok single line: '0.558508'

Test #14:

score: 5
Accepted
time: 1ms
memory: 4096kb

input:

8 15
2 1
3 1
5 1
5 2
5 4
6 1
6 2
7 1
7 2
7 3
7 5
8 2
8 3
8 4
8 5

output:

0.570480

result:

ok single line: '0.570480'

Test #15:

score: 5
Accepted
time: 0ms
memory: 3820kb

input:

8 18
3 1
4 3
5 4
6 2
6 4
6 5
7 1
7 2
7 3
7 4
7 5
8 1
8 2
8 3
8 4
8 5
8 6
8 7

output:

0.482269

result:

ok single line: '0.482269'

Test #16:

score: 5
Accepted
time: 1ms
memory: 3940kb

input:

8 18
2 1
3 2
4 2
4 3
5 2
5 3
5 4
6 2
6 3
7 1
7 2
7 3
7 4
7 5
7 6
8 1
8 3
8 5

output:

0.489007

result:

ok single line: '0.489007'

Test #17:

score: 5
Accepted
time: 5ms
memory: 4040kb

input:

10 22
2 1
4 1
5 1
5 2
6 1
6 2
6 5
7 1
7 2
7 4
7 6
8 3
8 4
8 6
9 3
9 4
9 7
10 1
10 2
10 4
10 6
10 8

output:

0.548805

result:

ok single line: '0.548805'

Test #18:

score: 5
Accepted
time: 5ms
memory: 3948kb

input:

10 22
3 1
3 2
4 3
5 3
6 2
6 3
6 4
7 1
7 2
7 4
7 5
7 6
8 4
9 1
9 3
9 4
9 6
10 1
10 2
10 3
10 7
10 8

output:

0.559280

result:

ok single line: '0.559280'

Test #19:

score: 5
Accepted
time: 6ms
memory: 3964kb

input:

10 25
3 1
4 1
5 2
5 3
5 4
6 1
6 4
6 5
7 2
7 4
8 1
8 3
8 5
8 7
9 1
9 2
9 4
9 6
9 7
10 2
10 3
10 6
10 7
10 8
10 9

output:

0.447754

result:

ok single line: '0.447754'

Test #20:

score: 5
Accepted
time: 6ms
memory: 3960kb

input:

10 25
3 2
4 3
5 1
5 2
5 4
6 3
6 4
7 1
7 5
8 1
8 3
8 4
8 6
8 7
9 1
9 2
9 3
9 4
9 6
9 7
10 2
10 4
10 5
10 6
10 8

output:

0.452142

result:

ok single line: '0.452142'