QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#568624#9242. An Easy Geometry ProblemWhaleAtColaRE 0ms0kbC++202.9kb2024-09-16 17:25:162024-09-16 17:25:17

Judging History

你现在查看的是最新测评结果

  • [2024-09-16 17:25:17]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2024-09-16 17:25:16]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define debug(...) fprintf(stderr,__VA_ARGS__)
typedef long long ll;
typedef double db;
inline ll read(){
	ll x=0;bool w=0;char c=getchar();
	while(c>'9'||c<'0') w|=c=='-',c=getchar();
	while(c>='0'&&c<='9') x=x*10+(c-'0'),c=getchar();
	return w?-x:x;
}

const int N=202020;
inline ll qpow(ll d,ll z,ll mod){
	ll res=1;
	for(;z;z>>=1,d=d*d%mod) if(z&1) res=res*d%mod;
	return res;
}
const ll bs1=10501,md1=1000000009,in1=qpow(bs1,md1-2,md1);
const ll bs2=15053,md2=998244353,in2=qpow(bs2,md2-2,md2);
//const ll bs1=100,md1=1000000009,in1=qpow(bs1,md1-2,md1);
//const ll bs2=100,md2=998244353,in2=qpow(bs2,md2-2,md2);
struct hsv{
	ll v1,v2;
	hsv(){v1=v2=0;}
	hsv(ll vv1,ll vv2){v1=vv1,v2=vv2;}
	inline void init(int v){v1=((v%md1)+md1)%md1,v2=((v%md2)+md2)%md2;}
	friend hsv operator +(hsv p,hsv q){return (hsv){(p.v1+q.v1)%md1,(p.v2+q.v2)%md2};}
	friend hsv operator -(hsv p,hsv q){return (hsv){(p.v1+md1-q.v1)%md1,(p.v2+md2-q.v2)%md2};}
	friend hsv operator *(hsv p,hsv q){return (hsv){(p.v1*q.v1)%md1,(p.v2*q.v2)%md2};}
	friend bool operator ==(hsv p,hsv q){return p.v1==q.v1&&p.v2==q.v2;}
};

const hsv bas=(hsv){bs1,bs2},inv=(hsv){in1,in2},zro;
hsv pwb[N],in[N];
int n,k,b,a[N];
hsv bsk;

struct bitree{
	hsv f[N];
	inline void upd(int p,hsv v){for(;p<=n;p+=(p&-p)) f[p]=f[p]+v;}
	inline hsv ask(int p){hsv res;for(;p;p^=(p&-p)) res=res+f[p];return res;}
}bit[2];

inline hsv ask(int k,int p){
	if((k--)==1) p=n-p+1;
	return bit[k].ask(p);
}
inline hsv upd(int k,int p,hsv vl){
//	debug("upd:%d %d %lld %lld\n",k,p,vl.v1,vl.v2);
	if((k--)==1) p=n-p+1;
	bit[k].upd(p,vl*pwb[p-1]);
}

inline hsv hs1(int l,int r){return (ask(1,l)-ask(1,r+1))*in[n-r];}
inline hsv hs2(int l,int r){return (ask(2,r)-ask(2,l-1))*in[l-1];}
inline void mdf(int ps,int v){
	a[ps]+=v;
	hsv vl;vl.init(v);
	upd(1,ps,vl),upd(2,ps,zro-vl);
}

inline int qry(int i){
//	debug("%d %d %d\n",a[i],a[i+1],b);
	if(i==n||(a[i]+a[i+1])!=b) return 0;
	int res=1,l=2,r=min(i-1,n-(i+2)+1),d;
	while(l<=r){
		d=(l+r)/2;
//		debug("%d %d %d  %lld %lld  %lld %lld\n",
//			l,r,d,hs1(i-d+1,i-1).v1,hs1(i-d+1,i-1).v2,hs2(i+2,i+d).v1,hs2(i+2,i+d).v2);
		if(hs1(i-d+1,i-1)==hs2(i+2,i+d)) res=d,l=d+1;
		else r=d-1;
	}
	return res;
}

inline void rmain(){
	n=read();
	pwb[0].init(1);
	for(int i=1;i<=n;++i) pwb[i]=pwb[i-1]*bas;
	in[0].init(1);
	for(int i=1;i<=n;++i) in[i]=in[i-1]*inv;

	int q=read();k=read(),b=read()+k;
	for(int i=1;i<=n;++i) a[i]=read();
	for(int i=n;i>=1;--i) a[i]=a[i]-a[i-1];
	bsk.init(k);
	for(int i=1;i<=n;++i){
		static hsv vl;vl.init(a[i]);
		upd(1,i,vl),upd(2,i,bsk-vl);
	}

	for(int i=1,op,l,r,v;i<=q;++i){
		op=read();
		if(op==1){
			l=read(),r=read(),v=read(),mdf(l,v);
			if(r<n) mdf(r+1,-v);
		}else if(op==2){
			l=read(),printf("%d\n",qry(l));
		}
	}
}

signed main(){
//	int T=read();while(T--)
	rmain();
	return 0;
}


Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Runtime Error

input:

6 6 6 2
1 5 9 10 15 18
2 2
1 3 3 -3
2 2
1 3 4 3
2 3
2 4

output:


result: