QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#812153 | #7329. Independent Events | zhenjianuo2025 | RE | 1660ms | 8464kb | C++14 | 6.4kb | 2024-12-13 12:01:54 | 2024-12-13 12:02:00 |
Judging History
answer
//%^~
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
// #include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <string>
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <limits>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include<bits/stdc++.h>
// #include "ext/pb_ds/assoc_container.hpp"
// #include "ext/pb_ds/tree_policy.hpp"
// #include "ext/pb_ds/priority_queue.hpp"
// #include <ext/rope>
// #define PBDS __gnu_pbds
// #include <bits/extc++.h>
#define MAXN 200005
#define eps 1e-10
#define foru(a, b, c) for (int a = (b); (a) <= (c); (a)++)
#define ford(a, b, c) for (int a = (b); (a) >= (c); (a)++)
#define uLL unsigned long long
#define LL long long
#define LXF int
#define RIN Cap1taLDebug::read()
#define RSIN Cap1taLDebug::rdstr()
#define RCIN Cap1taLDebug::rdchar()
#define HH printf("\n")
#define double long double
#define All(x) (x).begin(), (x).end()
#define fi first
#define se second
#define CA const auto&
using namespace std;
// const int RANDOM = time(0);
// template<class T1,class T2>
// class tr1::hash<pair<T1,T2>>{
// public:
// size_t operator () (pair<T1,T2> x)const{
// tr1::hash<T1> H1;
// tr1::hash<T2> H2;
// return H1(x.fi)^H2(x.se)^RANDOM;
// }
// };
int ID;
class Cap1taLDebug{
#ifdef LXF
#define READTYPE LXF
#else
#define READTYPE int
#endif
#define DEBUGING
private:
ostream& buf;
#ifndef DEBUGING
static char fbuf[1<<21],*p1,*p2;
#define getchar() (Cap1taLDebug::p1==p2&&(p1=(p2=fbuf)+fread(fbuf,1,1<<21,stdin),p1==p2)?EOF:*p2++)
#endif
public:
Cap1taLDebug(ostream& out=cout):buf(out){}
~Cap1taLDebug(){
#ifdef DEBUGING
buf.flush();
#endif
}
static READTYPE read(){
READTYPE x=0,w=1;char ch=0;
while(!isdigit(ch)){
if(ch=='-') w=-1;
ch=getchar();
}
while(isdigit(ch)) x=x*10+(ch^48),ch=getchar();
return x*w;
}
static string rdstr(){
string s;char c=getchar();
while(c==' ' || c=='\r' || c=='\n') c=getchar();
while(c!=' ' && c!='\r' && c!='\n' && c!=EOF) s+=c,c=getchar();
return s;
}
static char rdchar(){
char c=getchar();
while(c==' ' || c=='\r' || c=='\n') c=getchar();
return c;
}
static string int128ToString(__int128 x){
if(x==0) return "0";
string s="",w="";
if(x<0) w="-",x*=-1;
while(x) s+=(char)('0'+(int)(x%10)),x/=10;
reverse(All(s));
return w+s;
}
Cap1taLDebug& operator<<(const string val){
#ifdef DEBUGING
buf<<val;
#endif
return *this;
}
template<typename T1,typename T2>
Cap1taLDebug& operator<<(const pair<T1,T2>& val){
#ifdef DEBUGING
(*this)<<"("<<val.first<<","<<val.second<<")";
#endif
return *this;
}
template<typename T,template<typename,typename...>class Container,typename...Args>
Cap1taLDebug& operator<<(const Container<T, Args...>& container){
#ifdef DEBUGING
buf<<"{";
bool fst=0;
for(const auto& val:container){
if(!fst) fst=true;
else buf<<",";
(*this)<<val;
}
buf<<"}";
#endif
return *this;
}
Cap1taLDebug& operator<<(const __int128& val){
#ifdef DEBUGING
buf<<int128ToString(val);
#endif
return *this;
}
template<typename T>
Cap1taLDebug& operator<<(const T& val){
#ifdef DEBUGING
buf<<val;
#endif
return *this;
}
Cap1taLDebug& operator<<(ostream& (*manip)(ostream&)){
#ifdef DEBUGING
buf<<manip;
#endif
return *this;
}
};
#ifndef DEBUGING
char Cap1taLDebug::fbuf[1<<21],*Cap1taLDebug::p1=nullptr,*Cap1taLDebug::p2=nullptr;
#endif
Cap1taLDebug cein(cout);
// Cap1taLDebug cein(cerr);
ostream& operator<<(ostream& os,__int128 val){
os<<Cap1taLDebug::int128ToString(val);
return os;
}
template<typename T>
class Stack : public stack<T>{
public:
void clear(){
while(!this->empty()) this->pop();
}
void popuntil(const function<bool(T)>& func){
while(!this->empty() && !func(this->top())) this->pop();
}
};
/*
*/
int n,m;
double a[MAXN];
class SegTree{
public:
int l,r;
double sum;
double tg;
}tr[MAXN<<2];
inline int lc(int x){return x<<1;}
inline int rc(int x){return x<<1|1;}
void push_up(int p){
tr[p].sum=tr[lc(p)].sum+tr[rc(p)].sum;
}
void update(int p,double k){
tr[p].sum*=k;
tr[p].tg*=k;
}
void push_down(int p){
if(tr[p].tg!=1){
update(lc(p),tr[p].tg);
update(rc(p),tr[p].tg);
tr[p].tg=1;
}
}
void Build(int p,int l,int r){
tr[p].l=l,tr[p].r=r;
tr[p].sum=0;
tr[p].tg=1;
if(l==r){
tr[p].sum=a[l];
return ;
}
int mid=(tr[p].l+tr[p].r)>>1;
Build(lc(p),l,mid);
Build(rc(p),mid+1,r);
push_up(p);
}
void Modify(int p,int l,int r,double k){
if(l<=tr[p].l && tr[p].r<=r){
update(p,k);
return ;
}
push_down(p);
int mid=(tr[p].l+tr[p].r)>>1;
if(l<=mid) Modify(lc(p),l,r,k);
if(r>mid) Modify(rc(p),l,r,k);
push_up(p);
}
double Query(int p,int l,int r){
if(l<=tr[p].l && tr[p].r<=r) return tr[p].sum;
int mid=(tr[p].l+tr[p].r)>>1;
double ret=0;
push_down(p);
if(l<=mid) ret+=Query(lc(p),l,r);
if(r>mid) ret+=Query(rc(p),l,r);
return ret;
}
double ln(double x){
return log(x);
}
const int B=10000;
void solve(bool SPE){
while(cin>>n){
assert(n<=B);
cin>>m;
foru(i,1,n){
cin>>a[i];
}
Build(1,1,n);
while(m--){
int opt;
cin>>opt;
if(opt==1){
int l,r;
double k;
cin>>l>>r>>k;
Modify(1,l,r,k);
}else{
int l,r;
cin>>l>>r;
// double ans=0;
// if(r-l+1<=B){
// foru(i,l,r){
// double x=Query(1,i,i);
// ans+=ln(1.0-x);
// }
// }else{
double ans=0;
int i=l;
for(;i+B<=r;i+=B){
double x=Query(1,i,i+B-1)/(double)B;
ans+=(double)B*ln(1.0-x);
}
for(;i<=r;i++){
ans+=ln(1.0-Query(1,i,i));
}
// }
#undef double
printf("%.20lf\n",(double)ans);
}
}
}
#ifdef DEBUGING
if(SPE){
}
#endif
return ;
}
/*
检查文件读写
检查多测清空
检查数组大小
*/
signed main()
{
// #define RFILE
// #define MULTITEST
// #define TESTCASEID
ios::sync_with_stdio(0);
cin.tie(0),cout.tie(0);
#ifdef RFILE
freopen(".in","r",stdin);
freopen(".out","w",stdout);
#endif
#ifdef MULTITEST
int T=RIN;
#else
int T=1;
#endif
#ifdef TESTCASEID
ID=RIN;
#endif
for(int i=1;i<=T;i++) solve(i==0);
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 5964kb
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.16021487727848474081 -0.25587417689480757010 -0.14734347732072095027
result:
ok 3 numbers
Test #2:
score: 0
Accepted
time: 166ms
memory: 6080kb
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.00094044207705666746 -0.17285693984128142064 -0.64724368410974253418 -0.00144732047221210144 -0.09295564190549820971 -0.93078328060097825780 -0.06410239318769475614 -0.09166404281803548770 -0.04774269239055688174 -0.00085018090138477365 -0.03185781098379997928 -0.23731222356479128588 -0.517538000...
result:
ok 49679 numbers
Test #3:
score: 0
Accepted
time: 69ms
memory: 5976kb
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.11234334353646578675 -0.06540972096058840501 -0.00070024511439339195 -0.00079031221444377008 -0.00042008822470378189 -0.03031012007523891869 -0.22314667967829177053 -0.23039835923016496744 -0.23109860434455833933 -0.06119075875847015955 -0.03442884130322685504 -0.19239907802427019812 -0.041068196...
result:
ok 49929 numbers
Test #4:
score: 0
Accepted
time: 1660ms
memory: 8464kb
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.25383483182050170512 -1.20091333485136253501 -4.83376522734095548373 -6.51824680115526700064 -4.75304132895725839347 -6.78931476906469377752 -1.01552586349810392008 -0.92628338022877920732 -6.03469117983051628329 -2.98820177605649917041 -7.72666467593490402521 -1.08031515561991842134 -6.670126007...
result:
ok 50073 numbers
Test #5:
score: 0
Accepted
time: 167ms
memory: 6008kb
input:
17 103 0.05363 0.09209 0.03209 0.01593 0.06746 0.07370 0.00889 0.02883 0.02923 0.01899 0.07308 0.09632 0.06342 0.02905 0.06267 0.00986 0.08607 0 9 16 0 1 13 0 7 16 0 11 15 0 6 16 1 2 12 0.29850 1 3 15 1.07403 1 6 7 1.70767 0 2 3 1 4 12 2.03798 0 5 16 1 3 17 0.51591 0 2 13 1 4 6 1.54691 0 4 5 0 7 14 ...
output:
-0.39563575857451233064 -0.67651661449835887030 -0.43381925917076002985 -0.33688849311982055346 -0.51037638189291523183 -0.03821502920540667536 -0.48739964403027152828 -0.22987323399959658232 -0.04415067969302214484 -0.14116948919146618535 -0.04044274492071074645 -0.05616189746191511262 -0.055121665...
result:
ok 50134 numbers
Test #6:
score: 0
Accepted
time: 1637ms
memory: 6724kb
input:
1033 2717 0.00253 0.00437 0.00744 0.00171 0.00918 0.00727 0.00474 0.00776 0.00963 0.00289 0.00979 0.00582 0.00136 0.00251 0.00495 0.00481 0.00549 0.00589 0.00875 0.00696 0.00313 0.00590 0.00133 0.00298 0.00368 0.00440 0.00992 0.00505 0.00718 0.00321 0.00612 0.00612 0.00694 0.00824 0.00732 0.00506 0....
output:
-15.16732765815470429516 -2.82196222083586212293 -10.50258551047534183454 -3.23071999916261098917 -1.76882786613312759094 -0.15987139224354854350 -2.97595039298303598585 -1.30863347135521790321 -5.78894785262577915574 -5.92436023170347958455 -0.78854934149054878301 -5.90053421119978604992 -4.3944604...
result:
ok 50323 numbers
Test #7:
score: 0
Accepted
time: 76ms
memory: 6052kb
input:
43 1 0.00466 0.00427 0.00409 0.00337 0.00412 0.00225 0.00235 0.00458 0.00300 0.00176 0.00223 0.00276 0.00410 0.00457 0.00129 0.00359 0.00432 0.00422 0.00311 0.00268 0.00270 0.00194 0.00135 0.00103 0.00175 0.00494 0.00460 0.00126 0.00438 0.00310 0.00246 0.00451 0.00122 0.00438 0.00336 0.00436 0.00210...
output:
-0.00348606928483182052 -0.00917712698287607292 -0.01166816563077833005 -0.11610460009743239773 -0.15541924783669569532 -0.25469589037010792465 -0.20509401924998588163 -0.31908848562863584286 -0.16627666208553032456 -0.07394133948551062652 -0.16531703634409425363 -0.02458204174678989620 -0.276475511...
result:
ok 50228 numbers
Test #8:
score: 0
Accepted
time: 146ms
memory: 6084kb
input:
169 109 0.00287 0.00227 0.00326 0.00125 0.00399 0.00434 0.00200 0.00297 0.00381 0.00372 0.00347 0.00247 0.00293 0.00319 0.00196 0.00178 0.00212 0.00286 0.00214 0.00275 0.00136 0.00209 0.00139 0.00218 0.00204 0.00414 0.00345 0.00140 0.00398 0.00241 0.00142 0.00392 0.00263 0.00182 0.00137 0.00253 0.00...
output:
-0.31699232564564255865 -0.58711881037315516441 -0.13350233560470561867 -2.30498090527367294200 -0.56817735856468087885 -1.29396423026600659867 -0.60382948288306825813 -0.45109343457771461372 -1.12574399851044648635 -0.69099610135258149324 -0.25534458060503800736 -0.92413000803156819529 -0.787400371...
result:
ok 50183 numbers
Test #9:
score: 0
Accepted
time: 146ms
memory: 6032kb
input:
47 31 0.00832 0.00849 0.00558 0.00815 0.00847 0.00582 0.00748 0.00705 0.00842 0.00508 0.00539 0.00808 0.00608 0.00996 0.00974 0.00602 0.00968 0.00672 0.00592 0.00766 0.00988 0.00696 0.00874 0.00811 0.00949 0.00595 0.00916 0.00909 0.00513 0.00683 0.00652 0.00802 0.00513 0.00879 0.00841 0.00694 0.0086...
output:
-0.01905244538762502701 -0.31389354357469917423 -0.04210542317925456551 -0.42539259998942735574 -0.39728466243264604074 -0.32440089264736404751 -0.25618900114587178640 -0.16803179341778992639 -0.25344894948787394240 -0.44975065637923133943 -0.40578184638229120029 -0.13617961500067288227 -0.014801282...
result:
ok 50055 numbers
Test #10:
score: -100
Runtime Error
input:
100000 100000 0.07052 0.05432 0.02598 0.00422 0.07238 0.00101 0.07600 0.04658 0.00480 0.01504 0.06582 0.00826 0.05593 0.04165 0.09413 0.06963 0.07130 0.08360 0.09242 0.03682 0.09865 0.02278 0.05314 0.00652 0.09322 0.01022 0.00953 0.05682 0.08935 0.04186 0.07096 0.07263 0.02055 0.04193 0.02111 0.0034...