QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#611969#9242. An Easy Geometry Problemi0streamWA 33ms12352kbC++143.0kb2024-10-05 00:47:372024-10-05 00:47:38

Judging History

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

  • [2024-10-05 00:47:38]
  • 评测
  • 测评结果:WA
  • 用时:33ms
  • 内存:12352kb
  • [2024-10-05 00:47:37]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const int N=2*1e5+100;
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],Pre[N];
const node B=(node){107,103};

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 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]),Pre[mid-l]));
	trl[t<<1|1]=pl(trl[t<<1|1],ml(trans(tag[t]),Pre[r-mid-1]));
	trr[t<<1]=pl(trr[t<<1],ml(trans(tag[t]),Pre[mid-l]));
	trr[t<<1|1]=pl(trr[t<<1|1],ml(trans(tag[t]),Pre[r-mid-1]));
	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),Pre[r-l]));
		trr[t]=pl(trr[t],ml(trans(k),Pre[r-l]));
		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]=Pre[0]=(node){1,1};
	for (int i=1;i<=n;i++){
		a[i]=read()*2-i*k;
		pre[i]=ml(pre[i-1],B);
		Pre[i]=pl(Pre[i-1],pre[i]);
	}
	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-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;
}

詳細信息

Test #1:

score: 100
Accepted
time: 2ms
memory: 12024kb

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: 33ms
memory: 12352kb

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'