QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#610986#9242. An Easy Geometry Problemi0streamWA 45ms12156kbC++143.2kb2024-10-04 18:36:482024-10-04 18:36:53

Judging History

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

  • [2024-10-04 18:36:53]
  • 评测
  • 测评结果:WA
  • 用时:45ms
  • 内存:12156kb
  • [2024-10-04 18:36:48]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const int N=2*1e5+100;
const ll B=23456789;
//const ll B=13331;
const ll P1=1000000007;
const ll P2=998244353;

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

struct node{
	ll x,y;
}trl[N<<2],trr[N<<2],pre[N];
const node nb=(node){386400434,518927103};
//const node nb=(node){356114031,346202824};

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 node pl(node a,node b){return (node){(a.x+b.x)%P1,(a.y+b.y)%P2};}
inline node ml(node a,node b){return (node){(a.x*b.x)%P1,(a.y*b.y)%P2};}
inline node mn(node a,node b){return (node){(a.x-b.x+P1)%P1,(a.y-b.y+P2)%P2};}
inline bool eq(node a,node b){return a.x==b.x && a.y==b.y;}
inline node trans(ll a){return (node){a%P1,a%P2};}

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(trans(tag[t]),ml(mn(pre[mid-l+1],trans(1)),nb)));
	trl[t<<1|1]=pl(trl[t<<1|1],ml(trans(tag[t]),ml(mn(pre[r-mid],trans(1)),nb)));
	trr[t<<1]=pl(trr[t<<1],ml(trans(tag[t]),ml(mn(pre[mid-l+1],trans(1)),nb)));
	trr[t<<1|1]=pl(trr[t<<1|1],ml(trans(tag[t]),ml(mn(pre[r-mid],trans(1)),nb)));
	tag[t]=0;
}

void build(int t,int l,int r){
	if (l==r){
		trl[t]=trans(a[l]);
		trr[t]=trans(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(trans(k),ml(mn(pre[r-l+1],trans(1)),nb)));
		trr[t]=pl(trr[t],ml(trans(k),ml(mn(pre[r-l+1],trans(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);
}

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

node 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]=(node){1,1};
	for (int i=1;i<=n;i++){
		a[i]=read()*2-i*k;
		pre[i]=ml(pre[i-1],trans(B));
	}
	build(1,1,n);
	while (Q--){
		op=read();
		if (op==1){
			l=read();r=read();v=read();
			modify(1,1,n,l,r,v*2);

		}else{
			t=read();
			if (t==1 || t==n){
				puts("0");
				continue;
			}
			modify(1,1,n,1,t-1,b*2);			
			int l=0,r=min(t-1,n-t)+1;
			while (l<r-1){
				int mid=l+r>>1;
				if (eq(queryr(1,1,n,t-mid,t),queryl(1,1,n,t,t+mid))) l=mid;
				else r=mid;
			}
			printf("%d\n",l);
			modify(1,1,n,1,t-1,-b*2);
		}
	}
	return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 9976kb

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: 45ms
memory: 12156kb

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:

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

result:

wrong answer 1st numbers differ - expected: '2', found: '0'