Bzoj 3925 Zjoi2015 After the earthquake in the fantasy township of the desired pressure DP

Source: Internet
Author: User

Topic: Given a non-connected graph with a number of points not exceeding 10, each edge has a random weight between [0,1], and the desired value of the maximum edge on the minimum spanning tree is obtained.

No regrets in this life into the east, the afterlife is willing to birth fantasy Township

Otz

First, since the weights are evenly distributed between [0,1], the probability of the same two-edge weights is 0. So we're only thinking of all the different sides.

If the maximum edge on the minimum spanning tree is x, then the edge of the weight less than x must not be able to connect the graph, and the <=x edge of the weighted value can be

So for an X, if we find the probability that the graph is not connected when only the edge of the edge is less than x, then this probability is the probability of the answer >=x

Let's set this probability to f (x) then this f (x) is actually a polynomial of x and the answer is ∫[0,1]f (x) dx

As to why the answer is f (x) the integral can be perceptual understood under ... I count dead early ...


Here's how to find F (x).

First, "The probability that the edge is less than X" is x so the question is equivalent to "the probability that the graph is not connected when the probability of X is present on each edge"

"Then it's the classic way." CLJ only said this ... Then I picked up a half-day code to react to how to do qaq I'm so weak qaq


This approach is similar to the practice of POJ1737 connectivity diagrams

First, we consider the complement method to find the probability of the graph connecting and then subtract it by 1.

Then we enumerate each of the induced sub-graphs to calculate the probability of this sub-graph connecting

First we select a point p in the sub-graph and enumerate which points are connected to P

Set p where the probability of the Unicom block Unicom Q,x is located between the link block and other points in a total of K-side, then this situation is not connected to the probability is q* (1-x) ^k

The probability of losing all the disconnected probabilities from 1 is that the state is connected ...


I can read the code if I don't understand the language before I die.


Attention to the accuracy of the problem long double to use __float128

#include <vector> #include <cstdio> #include <cstring> #include <iomanip> #include <iostream > #include <algorithm> #define M 15using namespace std; typedef __float128 LD;TYPEDEF Vector<long long> Poly; int n,m,a[m]; Poly pow_1_x[m*m],f[1<<10];    Poly operator + (const Poly &x,const Poly &y) {int i;    Poly Re (max (X.size (), Y.size ()), 0);    For (I=0;i<x.size (); i++) re[i]+=x[i];    For (I=0;i<y.size (); i++) re[i]+=y[i]; return re;}    Poly operator-(const Poly &x,const Poly &y) {int i;    Poly Re (max (X.size (), Y.size ()), 0);    For (I=0;i<x.size (); i++) re[i]+=x[i];    For (I=0;i<y.size (); i++) re[i]-=y[i]; return re;}    Poly operator * (const Poly &x,const Poly &y) {int i,j;    Poly Re (X.size () +y.size () -1,0);    For (I=0;i<x.size (), i++) for (J=0;j<y.size (); j + +) Re[i+j]+=x[i]*y[j]; return re;}    LD Integrate (const Poly &x) {int i;ld re=0; for (I=0;I&LT;x.size (); i++) re+= (LD) x[i]/(i+1); return re;}    int Count (int x) {int re=0;    for (; x;x-=x&-x) re++; return re;}    int main () {int i,j,k,x,y;    cin>>n>>m;        for (i=1;i<=m;i++) {scanf ("%d%d", &x,&y);        a[x]|=1<<y-1;    a[y]|=1<<x-1;    } new (&pow_1_x[0]) Poly ();    New (&pow_1_x[1]) Poly (2,0);    Pow_1_x[1][0]=1;pow_1_x[1][1]=-1;    for (i=2;i<=m;i++) pow_1_x[i]=pow_1_x[i-1]*pow_1_x[1];        for (i=1;i<1<<n;i++) {new (&f[i]) Poly ();        for (x=1;x<=n;x++) if (i>>x-1&1) break;            For (j=i^ (1<<x-1); j; (--j) &=i^ (1<<x-1)) {int temp=i^j,cnt=0;            for (k=1;k<=n;k++) if (temp>>k-1&1) Cnt+=count (A[K]&AMP;J);        F[I]=F[I]-F[TEMP]*POW_1_X[CNT];    }} Poly Disconnect=poly (-f[) (1<<n)-1]; LD Ans=integrate (Disconnect);    Cout<<fixed<<setprecision (6) << (double) ans<<endl; return 0;}


Bzoj 3925 Zjoi2015 After the earthquake in the fantasy township of the desired pressure DP

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.