This is the case: the same program, running on my own computer is the correct result, and submitted to the CF evaluation machine for the same input data, the results are actually different! No problems were found after repeated checks. The suspicion may be related to memset at the moment, because when I change the AC code to close to my own program, I have the same condition (my program is exactly the same as the standard, and the code is almost identical).
Comparison of my program with the standard path:
My program:
#include <stdio.h>#include<string.h>Doublep[ +],ans[ +],dp[1<< -+ -];intMain () {//freopen ("Input.txt", "R", stdin); intn,k; scanf ("%d%d",&n,&K); memset (ans,0,sizeof(ans)); Memset (DP,0,sizeof(DP)); for(intI=0; i<n;i++) scanf ("%LF",&P[i]); dp[0]=1; for(intI=1;i< (1<<N); i++) { Doublesp=0; intCnt=0; for(intj=0; j<n;j++) if((i& (1<<J)) = =0) {CNT++; SP+=P[j]; } if(n-cnt>k)Continue; for(intj=0; j<n;j++) { if(p[j]<0.000000001)Continue; if(((1<<J) &i)! =0) {Dp[i]+=dp[i-(1<<J)]*p[j]/(sp+P[j]); ANS[J]+=dp[i-(1<<J)]*p[j]/(sp+P[j]); } } } for(intI=0; i<n;i++) printf ("%.9LF", Ans[i]); //fclose (stdin); return 0;}
View Code
Standard process:
#include <stdio.h>intN, K;Doublep[ A];Doubleans[ A];Doubledp[1<< -+ -];intMain () {intK; Doublesp; scanf ("%d%d", &n, &K); for(inti =0; i < N; i++) {scanf ("%LF", &P[i]); } dp[0] =1; for(inti =1; I < (1<< N); i++) {SP=0; K=0; for(intj =0; J < N; J + + ) { if( ( (1<< j) &i) = =0) {SP+=P[j]; K++; } } if(N-k > K)Continue; for(intj =0; J < N; J + + ) { if(P[j] <0.000000001)Continue; if( ( (1<< j) &i)! =0) {Dp[i]+ = Dp[i-(1<< j)] * P[j]/(sp +P[j]); ANS[J]+ = Dp[i-(1<< j)] * P[j]/(sp +P[j]); } } } for(inti =0; i < N; i++) {printf ("%.10LF", Ans[i]); } return 0;}
View Code
Submit Record:
Error Result:
I swear, running on my own computer, whether it is my own program or the standard process, the output is the correct result, but a submission, the result is wrong.
From Codeforces round 363