"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