QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#638638#5914. Falling Diamondskidkids28 3ms14480kbC++142.1kb2024-10-13 16:28:162024-10-13 16:28:21

Judging History

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

  • [2024-10-13 16:28:21]
  • 评测
  • 测评结果:28
  • 用时:3ms
  • 内存:14480kb
  • [2024-10-13 16:28:16]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int sz = 1200;
int arr[sz];
double dp[sz][sz];
void solve(int d){
    int a,b,c;
    cin>>a>>b>>c;
    b = abs(b);
    int idx = lower_bound(arr,arr+1000,a) - arr;
    // cout<<idx;
    cout<<setprecision(6)<<fixed;
    if(a==arr[idx]&&b+c<=idx*2)
        cout<<"Case #" << d<< ": 1.00\n";
    else if(b+c<idx*2)
        cout<<"Case #" << d<< ": 1.00\n";
    else if(b+c>idx*2)
        cout<<"Case #" << d<< ": 0.00\n";
    else if(b==0)
        cout<<"Case #" << d<< ": 0.00\n";
    else{
        int e = a - arr[idx-1];
        int bnd = (arr[idx]-arr[idx-1])/2;
        // cout<<e<<' '<<(arr[idx]-arr[idx-1])/2<<'\n';
        double ans = 0;
        if(bnd>=e){
            for(int i=c+1;i<=e;i++){
                // cout<<i<<' ';
                ans += dp[e][i];
            }
        }
        else{
            int cng = e - bnd;
            c-=cng;
            e-=2*cng;
            // cout<<cng<<c<<e;
            if(c<0){
                cout<<"Case #" << d<< ": 1.00\n";
                return;
            }
            for(int i=c+1;i<=e;i++){
                // cout<<i<<' ';
                ans += dp[e][i];
            }
            ans = ans;
        }
        cout<<"Case #" << d<< ": "<< ans << '\n';
    }
}
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int a;
    cin>>a;
    int cur = 1;
    arr[0] = 1;
    double two = 2.0l;
    for(int i = 1;i<sz;i++){
        cur+= 4 * i + 1;
        arr[i] = cur;
    }
    double f = 1.0l;
    for(int i = 0;i<sz;i++){
        dp[i][0] = f;
        dp[i][i] = f;
        f/=two;
    }
    for(int i = 1;i<sz;i++){
        for(int j = 1;j<i;j++){
            dp[i][j] = dp[i-1][j]/two + dp[i-1][j-1]/two;
        }
    }
    // for(int i = 0;i<7;i++){
    //     for(int j = 0;j<=i;j++){
    //         cout<<dp[i][j]<<' ';
    //     }
    //     cout<<'\n';
    // }
    // for(int i = 0;i<1000;i++){
    //     cout<<arr[i]<<'\n';
    // }

    for (int i=0;i<a;i++) {
        solve(i+1);
    }
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 3ms
memory: 14480kb

input:

100
12 2 0
3 -1 1
6 2 0
1 -2 0
15 1 3
11 -2 0
18 1594 0
14 2 2
7 0 0
20 8378 0
5 2 0
19 -3 3
8 6729 8897
16 -2036 0
5 0 2
19 -2 4
17 -2 0
11 -3 1
1 2 0
9 0 2058
6 0 2
8 0 0
1 0 2
6 -2 0
17 2 2
20 0 4
20 -4 2
10 -1 3
6 2 0
4 -686 0
15 9884 4748
19 0 4
17 0 0
4 0 0
15 0 4
7 2 0
5 0 2
7 265 9277
15 0 4...

output:

Case #1: 1.00
Case #2: 0.250000
Case #3: 1.00
Case #4: 0.00
Case #5: 1.00
Case #6: 1.00
Case #7: 0.00
Case #8: 1.00
Case #9: 1.00
Case #10: 0.00
Case #11: 1.00
Case #12: 0.062500
Case #13: 0.00
Case #14: 0.00
Case #15: 0.00
Case #16: 0.000000
Case #17: 1.00
Case #18: 0.875000
Case #19: 0.00
Case #20...

result:

wrong answer read 0.875000000000 but expected 0.812500000000 (test case 18)

Subtask #2:

score: 28
Accepted

Test #2:

score: 28
Accepted
time: 3ms
memory: 14260kb

input:

100
994903 -1410 0
216415 -10000 10000
9729 0 140
344476 830 0
240472 -694 0
988094 5473 715
970921 10000 10000
992898 -75 1211
760374 -10000 8290
92234 0 430
6 2 0
245786 -393 307
483518 -158 824
674606 1162 0
1000000 8520 0
4559 0 96
672200 -430 728
177309 0 596
124749 0 500
460023 464 494
18 -5 1...

output:

Case #1: 1.00
Case #2: 0.00
Case #3: 0.00
Case #4: 1.000000
Case #5: 0.500000
Case #6: 0.00
Case #7: 0.00
Case #8: 1.00
Case #9: 0.00
Case #10: 0.00
Case #11: 1.00
Case #12: 1.00
Case #13: 1.00
Case #14: 1.000000
Case #15: 0.00
Case #16: 0.00
Case #17: 1.00
Case #18: 0.00
Case #19: 0.00
Case #20: 1....

result:

ok correct! (100 test cases)