QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#597607#3247. 挑战ccpyWA 7ms35600kbC++141.3kb2024-09-28 18:09:342024-09-28 18:09:34

Judging History

你现在查看的是最新测评结果

  • [2024-09-28 18:09:34]
  • 评测
  • 测评结果:WA
  • 用时:7ms
  • 内存:35600kb
  • [2024-09-28 18:09:34]
  • 提交

answer

#include<bits/stdc++.h>
#define MAX 100005
using namespace std;
int n,p[MAX],q[MAX];
#define db long double
db f[1005][1005],g[1005][1005];
db h[MAX][3];
void sol(){
    cin>>n;
    for(int i=0;i<n;i++) cin>>p[i];
    for(int i=0;i<n;i++) cin>>q[i];
    h[n][0]=h[n][1]=h[n][2]=0;
    for(int i=n-1;~i;i--){
        for(int j=1;j<=p[i]&&i+j<=n;j++){
            h[i][0]=max(h[i][0],1-h[i+j][1]);
            h[i][1]=max(h[i][1],1-h[i+j][1]);
            h[i][2]=max(h[i][2],h[i+j][1]);
            if(j!=p[i]){
                db wn=f[p[i]-j][q[i]+q[i+j]];
                db ls=1-wn-g[p[i]-j][q[i]+q[i+j]];
                db rt=wn*h[i+j][0]+(1-wn-ls)*(1-h[i+j][1])+ls*(1-h[i+j][2]);
                //cout<<"i="<<i<<" "<<j<<" "<<wn<<" "<<ls<<endl;
                h[i][1]=max(h[i][1],rt);
            }
        }
        cout<<h[i][0]<<" "<<h[i][1]<<" "<<h[i][2]<<endl;
    }
    cout<<setprecision(18)<<h[0][1];
}
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int t=1;
    for(int i=1;i<=1000;i++){
        for(int j=1;j<=1000;j++){
            f[i][j]=f[i-1][j]*(i-1)/i;
            if(j<i) f[i][j]+=1.0/i;
            else f[i][j]+=1.0/(j+1);
            
            g[i][j]=g[i-1][j]*(i-1)/i;
            if(j>=i) g[i][j]+=1.0/(j+1)/i;
        }
    }
    while(t--) sol();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 7ms
memory: 35600kb

input:

1000
5 1 33 33 35 2 28 10 2 24 12 19 30 32 3 23 27 3 35 15 13 24 27 13 5 25 3 27 16 18 35 17 11 6 22 1 30 12 11 25 12 17 15 6 17 5 4 25 5 26 2 23 7 18 21 18 31 24 1 15 29 15 16 33 28 23 24 12 13 26 25 28 2 9 27 2 25 16 27 5 20 17 4 4 35 17 17 24 2 27 35 28 3 15 33 33 7 9 6 2 9 34 29 10 27 15 16 32 2...

output:

1 1 0
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
0 0 1
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
0 0.00493421 1
1 1 1
1 1 1
0.995066 0.995066 1
0.995066 0.995066 1
1 1 1
0.995066 0.995066 1
1 1 1
0.00493421 0.00493421 1
0.995066 0.995066 0.00493421
1 1 1
1 1 1
0.995066 0.995066 1
1 1 1
0.995066...

result:

wrong answer 1st numbers differ - expected: '0.9251428', found: '1.0000000', error = '0.0748572'