QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#226455#7329. Independent EventsPPP#RE 1286ms3960kbC++173.4kb2023-10-25 23:16:202023-10-25 23:16:20

Judging History

This is the latest submission verdict.

  • [2023-10-25 23:16:20]
  • Judged
  • Verdict: RE
  • Time: 1286ms
  • Memory: 3960kb
  • [2023-10-25 23:16:20]
  • Submitted

answer

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif
//#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;

#define pb push_back

typedef long long ll;
typedef long double ld;
int n, m;
const int maxN = 1e5 + 10;
ld p[maxN];
const int BUBEN = 40;
const int BLOCK = 2000;
ld F[maxN / BLOCK + 2][BUBEN];
int from[maxN / BLOCK + 2], to[maxN / BLOCK + 2];
ld coef[maxN / BLOCK + 2];
void solve() {
    for (int i = 0; i <= n / BLOCK; i++) {
        coef[i] = 0;
        for (int j = 0; j < BUBEN; j++) {
            F[i][j] = 0;
        }
    }
    for (int i = 0; i < n; i++) {
        cin >> p[i];
        int id = i / BLOCK;
        ld cur = 1;
        for (int j = 0; j < BUBEN; j++) {
            F[id][j] += cur;
            cur *= p[i];
        }
        p[i] = logl(p[i]);
    }
    for (int i = 0; i < n; i += BLOCK) {
        from[i / BLOCK] = i;
        to[i / BLOCK] = min(n, i + BLOCK);
    }
    auto apply = [&](int bl) {
        for (int k = 0; k < BUBEN; k++) {
            F[bl][k] = 0;
        }
        for (int j = from[bl]; j < to[bl]; j++) {
            p[j] += coef[bl];
            ld cur = 1;
            ld T = expl(p[j]);
            for (int k = 0; k < BUBEN; k++) {
                F[bl][k] += cur;
                cur *= T;
            }
        }
        coef[bl] = 0;
    };
    while (m--) {
//        if (m % 500 == 0) {
//            for (int z = 0; z < n; z += BLOCK) {
//                apply(z / BLOCK);
//            }
//        }
        int tp, l, r;
        cin >> tp >> l >> r;
        l--;
        r--;
        if (tp == 0) {
            int bl = l / BLOCK;
            int br = r / BLOCK;
            ld ans = 0;
            if (bl == br) {
                apply(bl);
                for (int j = l; j <= r; j++) {
                    ans += logl(1 - expl(p[j]));
                }
            }
            else {
                assert(false);
                apply(bl);
                apply(br);
                for (int j = bl + 1; j < br; j++) {
                    ld cur = 1;
                    ld T = expl(coef[j]);
                    for (int k = 1; k < BUBEN; k++) {
                        cur *= T;
                        ans += (F[j][k] * cur) / k;
                    }
                }
                ans *= -1;
                for (int j = l; j < to[bl]; j++) ans += logl(1 - expl(p[j]));
                for (int j = from[br]; j <= r; j++) ans += logl(1 - expl(p[j]));
            }
            cout << fixed << setprecision(25) << ans << '\n';
        }
        else {
            int bl = l / BLOCK;
            int br = r / BLOCK;
            ld k;
            cin >> k;
            k = logl(k);
            if (bl == br) {
                for (int j = l; j <= r; j++) {
                    p[j] += k;
                }
                apply(bl);
            }
            else {
                assert(false);
                for (int j = l; j < to[bl]; j++) p[j] += k;
                apply(bl);
                for (int j = from[br]; j <= r; j++) p[j] += k;
                apply(br);
                for (int j = bl + 1; j < br; j++) {
                    coef[j] += k;
                }
            }
        }
    }
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
#ifdef DEBUG
    freopen("input.txt", "r", stdin);
#endif
    while (cin >> n >> m) {
        solve();
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3888kb

input:

6 5
0.01000 0.09871 0.00005 0.00999 0.01234 0.02345
0 1 6
1 3 4 10.00000
0 1 6
1 1 2 0.05000
0 1 6

output:

-0.1602148772784847465000015
-0.2558741768948075730855628
-0.1473434773207209407333562

result:

ok 3 numbers

Test #2:

score: 0
Accepted
time: 1286ms
memory: 3960kb

input:

54 36
0.00014 0.00020 0.00054 0.00084 0.00088 0.00095 0.00031 0.00077 0.00054 0.00050 0.00024 0.00057 0.00066 0.00029 0.00084 0.00031 0.00024 0.00091 0.00063 0.00069 0.00024 0.00041 0.00090 0.00057 0.00071 0.00031 0.00047 0.00016 0.00063 0.00074 0.00040 0.00077 0.00058 0.00049 0.00013 0.00076 0.0007...

output:

-0.0009404420770566674953012
-0.1728569398412814198991031
-0.6472436841097425294666058
-0.0014473204722121014674474
-0.0929556419054982144867011
-0.9307832806009783099517388
-0.0641023931876947552030042
-0.0916640428180354913689797
-0.0477426923905568801200872
-0.0008501809013847736001136
-0.0318578...

result:

ok 49679 numbers

Test #3:

score: 0
Accepted
time: 205ms
memory: 3820kb

input:

13 5
0.00046 0.00033 0.00056 0.00093 0.00039 0.00094 0.00096 0.00085 0.00059 0.00083 0.00032 0.00075 0.00036
1 4 6 46.93710
0 3 11
0 5 8
1 4 13 2.21652
1 4 8 0.13103
4 14
0.00070 0.00028 0.00042 0.00079
0 1 1
0 4 4
0 3 3
1 2 2 100.00000
0 1 4
1 2 3 1.93082
1 3 4 100.00000
0 1 4
1 2 4 1.03435
0 2 4
0...

output:

-0.1123433435364657859950707
-0.0654097209605883984887714
-0.0007002451143933919598224
-0.0007903122144437701296313
-0.0004200882247037818721767
-0.0303101200752389201914587
-0.2231466796782917598934498
-0.2303983592301649601188397
-0.2310986043445583520690272
-0.0611907587584701615123970
-0.0344288...

result:

ok 49929 numbers

Test #4:

score: -100
Runtime Error

input:

625 1069
0.00107 0.00141 0.00178 0.00124 0.00104 0.00133 0.00188 0.00168 0.00108 0.00183 0.00199 0.00171 0.00122 0.00170 0.00133 0.00188 0.00128 0.00186 0.00165 0.00190 0.00117 0.00137 0.00129 0.00152 0.00136 0.00137 0.00135 0.00137 0.00134 0.00160 0.00159 0.00134 0.00124 0.00191 0.00193 0.00122 0.0...

output:

-5.2538348318205015407590663
-1.2009133348513624459921387
-4.8337652273409551688734820
-6.5182468011552673193935437
-4.7530413289572586697274981
-6.7893147690646935303246390
-1.0155258634981038406075102
-0.9262833802287792248856407
-6.0346911798305159896869954
-2.9882017760564989748185705
-7.7266646...

result: