QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#811927 | #7329. Independent Events | 464zzyx | WA | 0ms | 34708kb | C++14 | 1.9kb | 2024-12-13 09:02:21 | 2024-12-13 09:02:21 |
Judging History
answer
#include<bits/stdc++.h>
#define ll long long
#define deb(x) cerr<<"deb:"<<__LINE__<<" "<<#x<<"="<<x<<"\n"
//#define getchar()(p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
using namespace std;
//char buf[1<<21],*p1=buf,*p2=buf;
inline ll read()
{
ll sum=0,l=1;char c=getchar();
while(!isdigit(c)){if(c=='-')l=-1;c=getchar();}
while(isdigit(c)){sum=(sum<<1)+(sum<<3)+(c^48);c=getchar();}
return sum*l;
}
const ll n=20;
double c[100100],tl[400100],tr[400100],ts[21][400100],tg[400100];
void Update(ll x)
{
for(ll i=1;i<=n;i++)ts[i][x]=ts[i][x*2]+ts[i][x*2+1];
}
void upd(ll x,double y)
{
tg[x]*=y;
double now=y;
for(ll i=1;i<=n;i++)
{
ts[i][x]*=now;
now*=y;
}
}
void Push(ll x)
{
if(tg[x]!=1)
{
upd(x*2,tg[x]);
upd(x*2+1,tg[x]);
tg[x]=1;
}
}
void Build(ll x,ll l,ll r)
{
tl[x]=l;
tr[x]=r;
tg[x]=1;
if(l==r)
{
c[l]=-c[l];
double now=c[l];
for(ll i=1;i<=n;i++)
{
ts[i][x]=now/i;
now*=c[l];
}
return;
}
ll mid=(l+r)/2;
Build(x*2,l,mid);
Build(x*2+1,mid+1,r);
Update(x);
}
void Add(ll x,ll l,ll r,double y)
{
if(l<=tl[x]&&tr[x]<=r)
{
upd(x,y);
return;
}
Push(x);
ll mid=(tl[x]+tr[x])/2;
if(l<=mid)Add(x*2,l,r,y);
if(mid<r)Add(x*2+1,l,r,y);
Update(x);
}
double Query(ll x,ll l,ll r)
{
if(l<=tl[x]&&tr[x]<=r)
{
double res=0;
ll pl=1;
for(ll i=1;i<=n;i++)
{
res+=ts[i][x]*pl;
pl*=-1;
}
return res;
}
Push(x);
ll mid=(tl[x]+tr[x])/2;
if(mid<l)return Query(x*2+1,l,r);
else if(r<=mid)return Query(x*2,l,r);
else return Query(x*2,l,r)+Query(x*2+1,l,r);
}
int main()
{
ll a=read(),b=read();
for(ll i=1;i<=a;i++)cin>>c[i];
Build(1,1,a);
for(ll i=1;i<=b;i++)
{
ll op=read(),d=read(),e=read();
if(op==1)
{
double f;
cin>>f;
Add(1,d,e,f);
}
else
{
printf("%.12lf\n",Query(1,d,e));
}
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 34708kb
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: 0ms
memory: 30688kb
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 output format Unexpected end of file - double expected