TCO Round 1 B DIV1 500 probability problem

Source: Internet
Author: User

"Test Instructions" now has some clues to the probability of each clue being found P[i], if clue I is known, then other clues may also be known, with vector<string> C given, c[i][j]= ' Y ' means know I this clue, J this clue can be directly known, Ask for the number of clues that are ultimately found to be expected.

All P[i] and not 1 ...

The probability that each clue is selected, by test instructions, if you know the number of I, then you can immediately know the other points, then you can first use the Floyd, to find out when the node I should know which nodes.

Then the double negation, n (1-p[i1]) (1-p[i2]) ... (1-p[ik]) is the answer, where select I1,i2,..., any of IK can select I.

#include <cstdio>#include<cstring>#include<cmath>#include<iostream>#include<algorithm>#include<Set>#include<map>#include<stack>#include<vector>#include<queue>#include<string>#include<sstream>#defineEPS 1e-9#defineAll (x) X.begin (), X.end ()#defineINS (x) Inserter (X,x.begin ())#definefor (i,j,k) for (int i=j;i<=k;i++)#defineMAXN 1005#defineMAXM 40005#defineINF 0X3FFFFFFFusing namespaceStd;typedefLong LongLL;intI,j,k,n,m,x,y,t,ans,big,cas,num;BOOLFlag;DoublePA[MAXN];classthetips{ Public:        DoubleSolve (Vector <string> C, Vector <int>p) {intn=c.size ();  for(k=0; k<n;k++)            {                 for(i=0; i<n;i++)                {                     for(j=0; j<n;j++)                    {                        if(i==j | | j==k | | i==k)Continue; if(c[i][k]=='Y'&& c[k][j]=='Y') c[i][j]='Y'; }                }            }                         for(i=0; i<n;i++) c[i][i]='Y';  for(i=0; i<n;i++) pa[i]=1; //For (i=0;i<n;i++) cout<<c[i]<<endl;                         for(j=0; j<n;j++)            {                 for(i=0; i<n;i++)                {                    if(c[i][j]=='Y') {Pa[j]*=1-p[i]*0.01; }                }            }            //for (i=0;i<n;i++) printf ("%d%f\n", I,pa[i]);                        Doublecn1=0;  for(i=0; i<n;i++) {ans+=1-Pa[i]; }            returnans; }            };

TCO Round 1 B DIV1 500 probability problem

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.