839E - Mother of Dragons
题意:
题解:
没仔细看,好像现在解决不了~
以后再补
先贴上dalao的代码

1 // God & me 2 // Fly ... 3 #include <bits/stdc++.h> 4 using namespace std; 5 typedef long long ll; 6 const int maxn = 40, C = 20; 7 8 int n, k, dp[1 << C]; 9 ll adj[maxn]; 10 int maxc(){ 11 for(int i = 0; i < n; i++) 12 for(int j = 0, x; j < n; j++) 13 cin >> x, adj[i] |= (ll) (x || i == j) << j; 14 for(int i = 1; i < (1 << max(0, n - C)); i++){ 15 int x = i; 16 for(int j = 0; j < C; j++) 17 if((i >> j) & 1) 18 x &= adj[j + C] >> C; 19 if(x == i) 20 dp[i] = __builtin_popcount(i); 21 } 22 for(int i = 1; i < (1 << max(0, n - C)); i++) 23 for(int j = 0; j < C; j++) 24 if((i >> j) & 1) 25 dp[i] = max(dp[i], dp[i ^ (1 << j)]); 26 int ans = 0; 27 for (int i = 0; i < (1 << min(C, n)); i++){ 28 int x = i, y = (1 << max(0, n - C)) - 1; 29 for (int j = 0; j < min(C, n); j++) 30 if ((i >> j) & 1) 31 x &= adj[j] & ((1 << C) - 1), y &= adj[j] >> C; 32 if (x != i) continue; 33 ans = max(ans, __builtin_popcount(i) + dp[y]); 34 } 35 return ans; 36 } 37 int main(){ 38 ios::sync_with_stdio(0), cin.tie(0); 39 cin >> n >> k; 40 int ans = maxc(); 41 long double x = (long double) k / ans; 42 cout << fixed << setprecision(8) << x * x * ans * (ans - 1) / 2 << ' '; 43 return 0; 44 }