QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#812154#7329. Independent Eventszhenjianuo2025WA 1ms6012kbC++146.4kb2024-12-13 12:02:332024-12-13 12:02:34

Judging History

This is the latest submission verdict.

  • [2024-12-13 12:02:34]
  • Judged
  • Verdict: WA
  • Time: 1ms
  • Memory: 6012kb
  • [2024-12-13 12:02:33]
  • Submitted

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=2;

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;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 6012kb

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.15798747103073149112
-0.25092987170881336789
-0.14459668202345599131

result:

wrong answer 1st numbers differ - expected: '-0.1602148773', found: '-0.1579874710', error = '0.0022274062'