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
| #include<bits/stdc++.h> using namespace std; #ifdef LOCAL #define debug(...) fprintf(stdout, ##__VA_ARGS__) #else #define debug(...) void(0) #endif
inline int read(){int x=0,f=1;char ch=getchar(); while(ch<'0'|| ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){ x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}return x*f;} #define Z(x) (x)*(x) #define pb push_back #define fi first #define se second
#define N 22
int n, m, i, j, k, S, T, b; int G[N<<1][N<<1], f[1<<N], g[1<<N], s, l, r, t, p; int h[1<<N], ini; double ans; signed main() { #ifdef LOCAL freopen("in.txt", "r", stdin); freopen("out.txt", "w", stdout); #endif
n=read(); S=read(); m=(n+1)/2; for(i=1; i<=n; ++i) { for(j=1; j<=n; ++j) G[i][j]=read(); } for(i=1; i<=n; ++i) for(j=1; j<i; ++j) if(G[i][j]) debug("%d %d\n", i, j); for(i=1; i<=n; ++i) G[i][i]=1;
l = 1; r = m; for(s=1; s<(1<<m); ++s) { for(i=l; i<=r; ++i) if((s>>i-1)&1) g[s]=max(g[s], g[s-(1<<i-1)]); k = __builtin_popcount(s); if(k != 1) { for(i=l; i<=r; ++i) if((s>>i-1)&1) break; debug("i : %d\n", i); if(!f[s-(1<<i-1)]) continue; for(j=l; j<=r; ++j) if( ((s>>j-1)&1) && !G[i][j]) break; if(j <= r) continue; } debug("%d is ok !\n", s); g[s] = f[s] = k; t = max(t, k); } debug("----\n"); l=r+1; r=n; b=l-1; for(i=l; i<=r; ++i) { for(j=1; j<=m; ++j) h[i]|=(1<<j-1)*G[i][j]; debug("h[%d] = %d\n", i, h[i]); } memset(f, 0, sizeof(f)); ini=(1<<m)-1; m=n-m; for(s=1; s<(1<<m); ++s) { k = __builtin_popcount(s); if(k != 1) { for(i=l; i<=r; ++i) if((s>>i-b-1)&1) break; debug("> %d\n", i); if(!f[s-(1<<i-b-1)]) continue; for(j=l; j<=r; ++j) if( ((s>>j-b-1)&1) && !G[i][j]) break; if(j <= r) continue; } f[s] = 1; for(i=l, p=ini; i<=r; ++i) if((s>>i-b-1)&1) p&=h[i]; debug("%d is ok ! p : %d\n", s, p); t = max(t, g[p]+k); } debug("t : %d\n", t); ans = S*S*(t-1); ans /= t*2; printf("%.7lf", ans) ; return 0; }
|