QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#394140#4230. Leaderboard Effectkevinshan#AC ✓1297ms174876kbC++172.7kb2024-04-20 06:23:222024-04-20 06:23:23

Judging History

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

  • [2024-04-20 06:23:23]
  • 评测
  • 测评结果:AC
  • 用时:1297ms
  • 内存:174876kb
  • [2024-04-20 06:23:22]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define all(x) x.begin(), x.end()
#define pb push_back
#define f first
#define s second

#define vi vector<int>
#define pi pair<int,int>
#define lb lower_bound
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define For(i,a) FOR(i,0,a)
#define trav(a,b) for(auto& a:b)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define sz(x) (int) x.size()
#define ld long double
#define vpi vector<pi>
#define pil pair<int, ld>
#define vpil vector<pil>

const int MX = 1e2+3;
const int MX2 = (1<<17) + 1;

ld fre[MX][MX2];
ld ans[18]; // current probabilities of solved
int r[20], c[20];
ld p[20];
ld upd_ans[MX][20];

// const ld eps=0.0001;
const ld eps=1e-12;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    if (fopen("input.in", "r")) {
        freopen("input.in", "r", stdin);
        freopen("output.out", "w", stdout);
    }

    cout<<fixed<<setprecision(30);
    int n,T;cin>>n>>T;
    fre[0][0] = 1;
    For(i,n) {
        cin>>r[i]>>c[i]>>p[i];
        assert(p[i]<=1);
    }

    // cout << "HI" << endl;
    FOR(t,0,T+1) {
        For(k,n) {
            ans[k] += upd_ans[t][k];
            assert(ans[k]<=1);
        }

        For(mask, 1<<n) if (fre[t][mask]>=eps) {
            ld tot_ans = 0;
            int tmp_cnt=0;
            For(k,n) if(((1<<k) & mask) == 0) {
                tot_ans += ans[k];
                tmp_cnt++;
            }
            For(k,n) if(((1<<k) & mask) == 0) {
                ld prob_will_read = (ld) 1/tmp_cnt;
                if(tot_ans>=eps) {
                    prob_will_read = ans[k]/tot_ans;
                }
                if (t+r[k] <= T) {
                    ld tmp = prob_will_read*fre[t][mask];
                    if(t+r[k]+c[k] <= T) {
                        upd_ans[t+r[k]+c[k]][k] += tmp * p[k];
                        fre[t+r[k]+c[k]][mask+(1<<k)] += tmp * p[k];
                    }
                    fre[t+r[k]][mask+(1<<k)] += tmp*(1-p[k]);

                }
            }
        }
    }
    // TODO: setprecision
    // cout << fix
    For(i,n) {
        cout << ans[i] << "\n";
    }

}

/**
 For(mask, 1<<n) trav(x, upd_read[t][mask]) {
            // go solve 
            int k = x.f;
            // + instead of | works too rt
            if(t+c[k] <= T)
                upd_solve[t+c[k]][mask+(1<<k)].pb({k, p[k]*x.s});
            // no solve
            fre[t][mask+(1<<k)] += (1-p[k])*x.s;
        }
        cout << "HI2" << endl;
        For(mask, 1<<n) trav(x, upd_solve[t][mask]) {
            ans[x.f] += x.s;
            fre[t][mask] += x.s;
        }
        cout << "HI3" << endl;
*/


Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3916kb

input:

4 42
10 10 0.75
10 10 0.75
10 12 1
10 12 1

output:

0.456250000000000000010842021725
0.456250000000000000010842021725
0.296875000000000000000000000000
0.296875000000000000000000000000

result:

ok 4 numbers

Test #2:

score: 0
Accepted
time: 1ms
memory: 3964kb

input:

4 42
10 12 0.75
10 12 0.75
10 10 1
10 10 1

output:

0.203125000000000000000000000000
0.203125000000000000000000000000
0.683238636363636363626507252977
0.683238636363636363626507252977

result:

ok 4 numbers

Test #3:

score: 0
Accepted
time: 0ms
memory: 3916kb

input:

5 100
40 60 0.6
40 61 1
10 40 0.3
10 40 0.4
10 40 0.5

output:

0.120000000000000000004336808690
0.000000000000000000000000000000
0.112628571428571428586495883906
0.159739682539682539691981190411
0.206444444444444444444275790773

result:

ok 5 numbers

Test #4:

score: 0
Accepted
time: 251ms
memory: 47888kb

input:

15 100
4 14 0.954205412740471
5 11 0.264054003774017
1 7 0.521673865442381
3 12 0.6756938980261
1 15 0.980129050876819
2 12 0.836645892885326
10 3 0.959863273940343
13 6 0.230786407526669
3 13 0.0575791282076707
6 5 0.706328060881614
1 15 0.662404274712202
2 13 0.715327416279894
11 2 0.9275847467499...

output:

0.546688359877918469986474853117
0.055519018134640315894506347461
0.393621390015831018415306055691
0.350874919132407677335901141635
0.667424408971862815254019046796
0.571222512096778140488172181843
0.799952215637303304428609718180
0.040005404222656650858338210630
0.006145048708623936918459690088
0.5...

result:

ok 15 numbers

Test #5:

score: 0
Accepted
time: 591ms
memory: 91208kb

input:

16 100
1 8 0.203833126785817
1 10 0.551151943064124
1 12 0.996220861387656
1 7 0.198656409543208
2 2 0.467994369421028
8 3 0.201277956430612
1 10 0.33397726300295
1 8 0.223430703554389
3 12 0.715363922664928
9 6 0.883743052774488
1 9 0.51636293824285
2 7 0.00210327442137626
6 11 0.978989778915285
1 ...

output:

0.085880479443676239443097343573
0.425292727246924784806651406721
0.937411149936098191386580485984
0.092224955657299519894674628279
0.433995932823674579990880229019
0.075522925684084964145846401162
0.173430794238006820461635987263
0.101752995151693555501374449657
0.534933335162994791475623429511
0.7...

result:

ok 16 numbers

Test #6:

score: 0
Accepted
time: 26ms
memory: 44056kb

input:

16 100
36 30 0.246284470931766
40 2 0.00729886464249319
34 9 0.969806174971755
2 27 0.700168809611093
2 49 0.00964738878291982
11 13 0.843818712396597
23 15 0.015695164745825
2 11 0.860911871987035
8 39 0.759047449661107
33 17 0.156016479857797
5 40 0.704380590007194
2 36 0.0742940485679995
13 17 0....

output:

0.022417364414375727761096521000
0.000671987468592315753909969726
0.188134004526025502029742790533
0.267402196062388514585968224413
0.000806452249446332916076847573
0.481207172814253152966093921017
0.001508624006811008322905067771
0.728900640076661160708573067302
0.093530246883961857064010338852
0.0...

result:

ok 16 numbers

Test #7:

score: 0
Accepted
time: 1ms
memory: 3780kb

input:

2 100
44 23 0.344489870631275
18 13 0.617983603136949

output:

0.344489870631274999995385249774
0.617983603136948999982620139848

result:

ok 2 numbers

Test #8:

score: 0
Accepted
time: 1297ms
memory: 174876kb

input:

17 100
1 6 0.618966248907732
1 6 0.126915204708293
4 7 0.35153234988752
2 3 0.0368548187261588
1 5 0.299571483949073
1 12 0.944530094804986
3 12 0.249408160616937
1 11 0.91317090384857
5 8 0.377638681694897
4 12 0.639080155811651
1 4 0.809300766237897
8 5 0.812731204986182
1 10 0.480107932016118
7 1...

output:

0.609720575689979553618905172563
0.066416288701702713981594051323
0.275964785966704592208185650715
0.011631665735761757313265426800
0.265396865461309363541609826487
0.927618705338806354436433782018
0.110452449892666685196467805247
0.900022818022774084378932052397
0.272454769762834505571333018614
0.5...

result:

ok 17 numbers

Test #9:

score: 0
Accepted
time: 664ms
memory: 123672kb

input:

17 85
8 6 0.9977
1 4 0.9459
5 9 0.0733
2 9 0.759
9 6 0.921
5 6 0.2015
2 8 0.9407
8 10 0.7806
5 3 0.864
4 4 0.0777
9 3 0.9518
8 2 0.8221
10 9 0.2471
4 8 0.4679
7 6 0.603
3 2 0.4067
5 5 0.8879

output:

0.586724513438699488664107573044
0.912953398873193028848545965692
0.006580616846759328766989263467
0.421056080635485692579026914539
0.460749784865351578354774816915
0.031503038347656685309346310739
0.749829850137239017470597302051
0.246898052933178958936164849869
0.741615869853233289506720671280
0.0...

result:

ok 17 numbers

Test #10:

score: 0
Accepted
time: 656ms
memory: 128168kb

input:

17 85
9 7 0.0563
7 7 0.1979
9 3 0.7689
1 6 0.0291
7 7 0.9631
5 8 0.847
8 6 0.6752
2 9 0.0396
4 2 0.6747
8 3 0.1071
8 4 0.5134
9 7 0.7491
6 8 0.3134
3 1 0.8355
4 5 0.5561
1 10 0.372
9 9 0.4515

output:

0.005494076785398813544666272697
0.037237798825585861068449521072
0.629437248338353164415961277234
0.003543465854637623856195069515
0.781023525176043393984659513052
0.677157936536342303101860401471
0.410806431456464594503775675238
0.003743883245543693570726195190
0.642440921965858139849880892314
0.0...

result:

ok 17 numbers

Test #11:

score: 0
Accepted
time: 800ms
memory: 133248kb

input:

17 85
1 7 0.1344
5 8 0.99
8 3 0.437
4 9 0.1375
3 2 0.8208
1 8 0.5922
10 6 0.655
8 5 0.8043
2 5 0.8447
5 10 0.3305
9 3 0.725
1 8 0.0394
6 5 0.8091
8 7 0.6427
9 6 0.7282
4 7 0.1024
1 6 0.4222

output:

0.027115033874418582911648527289
0.792437154583530142760647296818
0.206196776818740943362480780299
0.020443184310697101559577159614
0.797474379928793401057715573010
0.426878806431170063431530109499
0.285203944394767908447532039906
0.551883375084761839714231346221
0.792822131068646269807208282199
0.0...

result:

ok 17 numbers

Test #12:

score: 0
Accepted
time: 641ms
memory: 122000kb

input:

17 85
10 2 0.6556
3 1 0.7738
1 8 0.9047
3 10 0.9973
10 4 0.5266
8 1 0.4384
5 3 0.3559
3 6 0.7999
8 6 0.9665
3 4 0.142
7 5 0.0319
6 3 0.4056
6 10 0.0477
8 10 0.1334
5 8 0.8102
8 8 0.6
7 5 0.318

output:

0.397289121152491294476421720971
0.761422108317915281763387652658
0.831520189460210749834035565131
0.780827792823749047509442056114
0.196244886560547360820926966751
0.254090232200144444354083725357
0.190704609658676805711871420079
0.703615772826463597370682395704
0.680280807045156426290238860233
0.0...

result:

ok 17 numbers

Test #13:

score: 0
Accepted
time: 10ms
memory: 4448kb

input:

17 100
10 41 0.986344070444954
38 40 0.13596976314146
23 65 0.589188420670698
23 41 0.862487981086339
66 62 0.756039635351495
84 82 0.466671597793749
17 74 0.451825236037525
97 49 0.785964886639839
76 26 0.432545432217108
10 33 0.495053202758143
35 72 0.437261903429889
55 95 0.333190022475783
83 56 ...

output:

0.071557905030190761511588604799
0.008531951117393965681478021877
0.035781505339294679228761414391
0.057417466249548430566200301825
0.000000000000000000000000000000
0.000000000000000000000000000000
0.026577955061030882353138621484
0.000000000000000000000000000000
0.000000000000000000000000000000
0.0...

result:

ok 17 numbers

Test #14:

score: 0
Accepted
time: 13ms
memory: 4716kb

input:

17 100
52 66 0.608312285077897
77 36 0.182402129968963
43 16 0.906840075497175
75 100 0.508033408075313
25 60 0.688919263266595
84 59 0.17045120790047
75 9 0.831462171228754
16 69 0.185113485186001
71 54 0.372346884200038
90 65 0.235248490382517
62 50 0.917089563798644
47 45 0.717838729472597
56 51 ...

output:

0.000000000000000000000000000000
0.000000000000000000000000000000
0.060282814414062290468519908146
0.000000000000000000000000000000
0.041553544552179498506802590718
0.000000000000000000000000000000
0.052642288171709536636819464633
0.011165490448637735694646536209
0.000000000000000000000000000000
0.0...

result:

ok 17 numbers

Test #15:

score: 0
Accepted
time: 1ms
memory: 3944kb

input:

5 40
10 8 0.9
10 9 0.9
10 10 0.9
10 11 0.9
10 12 0.9

output:

0.538499999999999999934080507913
0.376499999999999999977014913943
0.241500000000000000012793585635
0.238500000000000000004553649124
0.238500000000000000004553649124

result:

ok 5 numbers