QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#610642#9242. An Easy Geometry Problemi0streamWA 26ms10192kbC++142.7kb2024-10-04 16:47:402024-10-04 16:47:41

Judging History

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

  • [2024-10-04 16:47:41]
  • 评测
  • 测评结果:WA
  • 用时:26ms
  • 内存:10192kb
  • [2024-10-04 16:47:40]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const int N=2*1e5+100;
const ll B=13331;
const ll P=1000000007;
const ll nb=356114031;

ll trl[N<<2],trr[N<<2],pre[N],tag[N<<2],a[N];
int n,Q,l,r,t,op;
ll k,b,v;

ll read(){
    ll flag=1,x=0,c=getchar();
    while (c<'0' || c>'9'){if (c=='-') flag=-1;c=getchar();}
    while (c>='0' && c<='9') x=x*10+c-48,c=getchar();
    return x*flag;
}

inline ll pl(ll a,ll b){return (a+b)%P;}
inline ll ml(ll a,ll b){return (a*b)%P;}
inline ll mn(ll a,ll b){return (a-b+P)%P;}

void pushup(int t,int l,int r){
	int mid=l+r>>1;
	trl[t]=pl(ml(trl[t<<1],pre[r-mid]),trl[t<<1|1]);
	trr[t]=pl(trr[t<<1],ml(trr[t<<1|1],pre[mid-l+1]));
}

void pushdown(int t,int l,int r){
	int mid=l+r>>1;
	tag[t<<1]+=tag[t];
	tag[t<<1|1]+=tag[t];
	trl[t<<1]=pl(trl[t<<1],ml(tag[t],ml(mn(pre[mid-l+1],1),nb)));
	trl[t<<1|1]=pl(trl[t<<1|1],ml(tag[t],ml(mn(pre[r-mid],1),nb)));
	trr[t<<1]=pl(trr[t<<1],ml(tag[t],ml(mn(pre[mid-l+1],1),nb)));
	trr[t<<1|1]=pl(trr[t<<1|1],ml(tag[t],ml(mn(pre[r-mid],1),nb)));
	tag[t]=0;
}

void build(int t,int l,int r){
	if (l==r){
		trl[t]=a[l];
		trr[t]=a[l];
		return;
	}
	int mid=l+r>>1;
	build(t<<1,l,mid);
	build(t<<1|1,mid+1,r);
	pushup(t,l,r);
}

void modify(int t,int l,int r,int x,int y,ll k){
	if (x<=l && r<=y){
		tag[t]+=k;
		trl[t]=pl(trl[t],ml(k,ml(mn(pre[r-l+1],1),nb)));
		trr[t]=pl(trr[t],ml(k,ml(mn(pre[r-l+1],1),nb)));
		return;
	}
	pushdown(t,l,r);
	int mid=l+r>>1;
	if (x<=mid) modify(t<<1,l,mid,x,y,k);
	if (y>mid) modify(t<<1|1,mid+1,r,x,y,k);
	pushup(t,l,r);
}

ll queryl(int t,int l,int r,int x,int y){
	if (x==l && r==y) return trl[t];
	pushdown(t,l,r);
	int mid=l+r>>1;
	if (y<=mid) return queryl(t<<1,l,mid,x,y);
	if (x>mid) return queryl(t<<1|1,mid+1,r,x,y);
	return pl(ml(queryl(t<<1,l,mid,x,mid),pre[y-mid]),queryl(t<<1|1,mid+1,r,mid+1,y));
}

ll queryr(int t,int l,int r,int x,int y){
	if (x==l && r==y) return trr[t];
	pushdown(t,l,r);
	int mid=l+r>>1;
	if (y<=mid) return queryr(t<<1,l,mid,x,y);
	if (x>mid) return queryr(t<<1|1,mid+1,r,x,y);
	return pl(queryr(t<<1,l,mid,x,mid),ml(queryr(t<<1|1,mid+1,r,mid+1,y),pre[mid-l+1]));
}

int main(){
	n=read();Q=read();k=read();b=read();
	pre[0]=1;
	for (int i=1;i<=n;i++){
		a[i]=read()*2-i*k;
		pre[i]=ml(pre[i-1],B);
	}
	build(1,1,n);
	while (Q--){
		op=read();
		if (op==1){
			l=read();r=read();v=read()*2;
			modify(1,1,n,l,r,v);
		}else{
			t=read();
			modify(1,1,n,1,t-1,b*2);
			int l=0,r=min(t-1,n-t)+1;
			while (l<r){
				if (l==r-1) break;
				int mid=l+r>>1;
				if (queryr(1,1,n,t-mid,t-1)==queryl(1,1,n,t+1,t+mid)) l=mid;
				else r=mid;
			}
			printf("%d\n",l);
			modify(1,1,n,1,t-1,-b*2);
		}
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 9968kb

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:

1
0
2
0

result:

ok 4 number(s): "1 0 2 0"

Test #2:

score: -100
Wrong Answer
time: 26ms
memory: 10192kb

input:

5000 5000 2 0
-329 -328 -327 -326 -325 -324 -323 -322 -321 -320 -319 -318 -317 -316 -315 -314 -313 -312 -311 -310 -309 -308 -307 -306 -305 -304 -303 -302 -301 -300 -299 -298 -297 -296 -295 -294 -293 -292 -291 -290 -289 -288 -287 -286 -285 -284 -283 -282 -281 -280 -279 -278 -277 -276 -275 -274 -273 -...

output:

2
8
1
1
1
2
2
4
1
2
1
2
2
3
2
12
1
1
4
1
13
1
6
2
1
1
6
1
2
2
14
2
1
2
1
5
2
1
3
5
1
11
3
1
2
2
2
1
2
1
1
2
11
1
1
1
2
2
1
2
1
2
2
1
1
2
1
1
1
1
1
3
2
1
1
5
1
5
1
1
1
1
1
3
3
2
1
1
1
1
3
1
1
1
4
1
2
1
4
1
3
1
7
1
4
14
2
7
1
1
1
1
2
11
1
3
2
1
1
2
1
3
2
6
1
2
1
3
3
2
2
1
2
1
2
0
1
9
2
4
1
4
1
2
2
1
1...

result:

wrong answer 2nd numbers differ - expected: '304', found: '8'