{"id":341,"date":"2010-08-11T20:19:00","date_gmt":"2010-08-11T12:19:00","guid":{"rendered":"http:\/\/localhost\/?p=341"},"modified":"2010-08-11T20:19:00","modified_gmt":"2010-08-11T12:19:00","slug":"interconnect_interconnect","status":"publish","type":"post","link":"https:\/\/www.shuizilong.com\/wjmzbmr\/?p=341","title":{"rendered":"Interconnect Interconnect"},"content":{"rendered":"\n<p>Interconnect Interconnect<\/p>\n<p>Time Limit:10000MS&#160; Memory Limit:65536K<br \/>Total Submit:48 Accepted:37 <br \/>Case Time Limit:1000MS<\/p>\n<p><strong>Description <\/strong><\/p>\n<p> \u7ed9\u51fa\u65e0\u5411\u56feG(V, E). \u6bcf\u6b21\u64cd\u4f5c\u4efb\u610f\u52a0\u4e00\u6761\u975e\u81ea\u73af\u7684\u8fb9(u, v), \u6bcf\u6761\u8fb9\u7684\u9009\u62e9\u662f\u7b49\u6982\u7387\u7684. \u95ee\u4f7f\u5f97G\u8fde\u901a\u7684\u671f\u671b\u64cd\u4f5c\u6b21\u6570. (|V|  &lt;= 30, |E| &lt;= 1000) <\/p>\n<p><strong>Input <\/strong><\/p>\n<p> \u7b2c\u4e00\u884c\u4e24\u4e2a\u6574\u6570N,M <br \/>1&lt;=N&lt;=30 <br \/>0&lt;=M&lt;=1000 <br \/>\u63a5\u4e0b\u6765M\u884c,\u6bcf\u884c\u4e24\u4e2a\u6574\u6570X,Y\u8868\u793a\u4e24\u8005\u4e4b\u95f4\u5df2\u4fee\u597d\u4e00\u6761\u9053\u8def. <br \/>\u4e24\u70b9\u4e4b\u95f4\u53ef\u4ee5\u4e0d\u6b62\u4fee\u4e86\u4e00\u6761\u8def,\u4e5f\u6709\u53ef\u80fdM\u6761\u8def\u5df2\u4f7fN\u4e2a\u70b9\u6210\u4e3a\u4e00\u4e2a\u6574\u4f53. <\/p>\n<p><strong>Output <\/strong><\/p>\n<p> \u8f93\u51fa\u4e00\u4e2a\u5c0f\u6570,\u8868\u793a\u65b0\u4fee\u9053\u8def\u6761\u6570\u7684\u671f\u671b\u503c,\u4fdd\u7559\u516d\u4f4d\u5c0f\u6570.<\/p>\n<p><strong>Sample Input <\/strong><\/p>\n<p>4 2<br \/>1 2 <br \/>3 4<\/p>\n<p><strong>Sample Output <\/strong><\/p>\n<p>1.500000<\/p>\n<p><strong>Source<br \/>\u8fd9\u4e2a\u9898\u76ee\u6211\u770b\u5230\u4e4b\u540e\u7b2c\u4e00\u611f\u89c9\u5c31\u662f\u72b6\u6001\u538b\u7f29Dp\u3002\u3002<br \/>\u72b6\u6001\u5c31\u662f\u5404\u4e2a\u8054\u901a\u5757\u7684\u5927\u5c0f\u3002\u3002<br \/>\u7136\u540e\u53d1\u73b0\u72b6\u6001\u6700\u591a\u53ea\u67095604\u4e2a\u3002\u3002<br \/>\u7136\u540e\u5c31\u53ef\u4ee5\u65e0\u538b\u529bDp\u4e86\u3002\u3002<br \/>\u4e3a\u4e86\u65b9\u4fbf\u6211\u4f7f\u7528\u4e86Map\u5b58\u6570\u636e\uff0cvector\u5b58\u72b6\u6001\uff0c<br \/>\u901f\u5ea6\u5947\u6162\u65e0\u6bd4\u3002\u3002<br \/><\/strong><\/p>\n<p>#include &lt;vector&gt;<br \/>#include &lt;algorithm&gt;<br \/>#include &lt;utility&gt;<br \/>#include &lt;iostream&gt;<br \/>#include &lt;cstdio&gt;<br \/>#include &lt;cmath&gt;<br \/>#include &lt;cstdlib&gt;<br \/>#include &lt;set&gt;<br \/>#include &lt;map&gt;<br \/>#include &lt;cstring&gt;<br \/>#include &lt;time.h&gt;<br \/>#define rep(i,n) for(int i=0;i&lt;n;i++)<br \/>#define pb push_back<br \/>#define Debug(x) cout&lt;&lt;#x&lt;&lt;&quot;=&quot;&lt;&lt;x&lt;&lt;endl;<br \/>#define For(i,l,r) for(int i=l;i&lt;=r;i++)<br \/>#define tr(e,x) for(VI::iterator e=x.begin();e!=x.end();e++)<br \/>#define printTime cout&lt;&lt;&quot;Time:&quot;&lt;&lt;pre-clock()&lt;&lt;endl;pre=clock();<br \/>const int inf=~0U&gt;&gt;1;<br \/>using namespace std;<br \/>typedef vector&lt;int&gt; VI;<br \/>map&lt;VI,double&gt; Map;<br \/>int n,m;<br \/>int total;<br \/>double Dp(VI A)<br \/>{<br \/>    if(Map.count(A))return Map[A];<br \/>    double&amp;x=Map[A];<br \/>    if(A.size()==1)return x=0;<br \/>    double same=0;<br \/>    rep(i,A.size())<br \/>        rep(j,i+1)<br \/>            if(i==j)<br \/>                same+=double(A[i]*(A[i]-1)\/2)\/total;<br \/>            else<br \/>            {<br \/>                VI New=A;<br \/>                New[i]+=New[j];swap(New[j],New[New.size()-1]);<br \/>                New.pop_back();sort(New.begin(),New.end());<br \/>                x+=double(A[i]*A[j])\/total*Dp(New);<br \/>            }<br \/>    x=(x+1)\/(1-same);<br \/>    return x;<br \/>}<br \/>int main()<br \/>{<br \/>    \/\/freopen(&quot;in&quot;,&quot;r&quot;,stdin);<br \/>    cin&gt;&gt;n&gt;&gt;m;total=n*(n-1)\/2;<br \/>    VI comp(n);<br \/>    rep(i,n)comp[i]=i;<br \/>    int s,t;<br \/>    rep(i,m)<br \/>    {<br \/>        cin&gt;&gt;s&gt;&gt;t;&#8211;s;&#8211;t;int that=comp[t];<br \/>        if(comp[s]!=comp[t])<br \/>            rep(j,n)if(comp[j]==that)<br \/>                comp[j]=comp[s];<br \/>    }<br \/>    VI count(n,0),Now;<br \/>    rep(i,n)count[comp[i]]++;<br \/>    rep(i,n)if(count[i])Now.pb(count[i]);<br \/>    sort(Now.begin(),Now.end());<br \/>    printf(&quot;%0.6lfn&quot;,Dp(Now));<br \/>    \/\/cout&lt;&lt;Map.size()&lt;&lt;endl;<br \/>}<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Interconnect Interconnect Time Limit:10000MS&#160; Memory Limit:65536KTotal Submit:48 Accepted:37 Case Time Limit:1000MS Description \u7ed9\u51fa\u65e0\u5411\u56feG(V, E). \u6bcf\u6b21\u64cd\u4f5c\u4efb\u610f\u52a0\u4e00\u6761\u975e\u81ea\u73af\u7684\u8fb9(u, v), \u6bcf\u6761\u8fb9\u7684\u9009\u62e9\u662f\u7b49\u6982\u7387\u7684. \u95ee\u4f7f\u5f97G\u8fde\u901a\u7684\u671f\u671b\u64cd\u4f5c\u6b21\u6570. (|V| &lt;= 30, |E| &lt;= 1000) Input \u7b2c\u4e00\u884c\u4e24\u4e2a\u6574\u6570N,M 1&lt;=N&lt;=30 0&lt;=M&lt;=1000 \u63a5\u4e0b\u6765M\u884c,\u6bcf\u884c\u4e24\u4e2a\u6574\u6570X,Y\u8868\u793a\u4e24\u8005\u4e4b\u95f4\u5df2\u4fee\u597d\u4e00\u6761\u9053\u8def. \u4e24\u70b9\u4e4b\u95f4\u53ef\u4ee5\u4e0d\u6b62\u4fee\u4e86\u4e00\u6761\u8def,\u4e5f\u6709\u53ef\u80fdM\u6761\u8def\u5df2\u4f7fN\u4e2a\u70b9\u6210\u4e3a\u4e00\u4e2a\u6574\u4f53. Output \u8f93\u51fa\u4e00\u4e2a\u5c0f\u6570,\u8868\u793a\u65b0\u4fee\u9053\u8def\u6761\u6570\u7684\u671f\u671b\u503c,\u4fdd\u7559\u516d\u4f4d\u5c0f\u6570. Sample Input 4 21 2 3 4 Sample Output 1.500000 Source\u8fd9\u4e2a\u9898\u76ee\u6211\u770b\u5230\u4e4b\u540e\u7b2c\u4e00\u611f\u89c9\u5c31\u662f\u72b6\u6001\u538b\u7f29Dp\u3002\u3002\u72b6\u6001\u5c31\u662f\u5404\u4e2a\u8054\u901a\u5757\u7684\u5927\u5c0f\u3002\u3002\u7136\u540e\u53d1\u73b0\u72b6\u6001\u6700\u591a\u53ea\u67095604\u4e2a\u3002\u3002\u7136\u540e\u5c31\u53ef\u4ee5\u65e0\u538b\u529bDp\u4e86\u3002\u3002\u4e3a\u4e86\u65b9\u4fbf\u6211\u4f7f\u7528\u4e86Map\u5b58\u6570\u636e\uff0cvector\u5b58\u72b6\u6001\uff0c\u901f\u5ea6\u5947\u6162\u65e0\u6bd4\u3002\u3002 #include &lt;vector&gt;#include &lt;algorithm&gt;#include &lt;utility&gt;#include &lt;iostream&gt;#include &lt;cstdio&gt;#include &lt;cmath&gt;#include &lt;cstdlib&gt;#include &lt;set&gt;#include &lt;map&gt;#include &lt;cstring&gt;#include &lt;time.h&gt;#define [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[10],"tags":[],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=\/wp\/v2\/posts\/341"}],"collection":[{"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=341"}],"version-history":[{"count":0,"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=\/wp\/v2\/posts\/341\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=341"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=341"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=341"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}