QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#226441 | #7329. Independent Events | PPP# | WA | 1054ms | 3756kb | C++17 | 3.3kb | 2023-10-25 23:08:55 | 2023-10-25 23:08:56 |
Judging History
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] = 1;
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];
}
}
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;
for (int k = 0; k < BUBEN; k++) {
F[bl][k] += cur;
cur *= p[j];
}
}
coef[bl] = 1;
};
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 - p[j]);
}
}
else {
assert(false);
apply(bl);
apply(br);
for (int j = bl + 1; j < br; j++) {
ld cur = 1;
for (int k = 1; k < BUBEN; k++) {
cur *= coef[j];
ans += (F[j][k] * cur) / k;
}
}
ans *= -1;
for (int j = l; j < to[bl]; j++) ans += logl(1 - p[j]);
for (int j = from[br]; j <= r; j++) ans += logl(1 - p[j]);
}
cout << fixed << setprecision(12) << ans << '\n';
}
else {
int bl = l / BLOCK;
int br = r / BLOCK;
ld k;
cin >> k;
if (bl == br) {
for (int j = l; j <= r; j++) {
p[j] *= k;
}
apply(bl);
}
else {
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: 1ms
memory: 3756kb
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.160214877278 -0.255874176895 -0.147343477321
result:
ok 3 numbers
Test #2:
score: -100
Wrong Answer
time: 1054ms
memory: 3712kb
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.000940442077 -0.172856939841 -0.647243684110 -0.001447320472 -0.092955641905 -0.930783280601 -0.064102393188 -0.091664042818 -0.047742692391 -0.000850180901 -0.031857810984 -0.237312223565 -0.517538000549 -0.653499425353 -0.301089175013 -0.062422318722 -0.476679973076 -0.317678112868 -0.393605508...
result:
wrong answer 159th numbers differ - expected: '-0.0003542665', found: '-0.0003542665', error = '0.0000000000'