QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#303359#7992. 【模板】线段树QOJ114514ancestorWA 2546ms65080kbC++141.8kb2024-01-12 09:56:202024-01-12 09:56:22

Judging History

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

  • [2024-01-12 09:56:22]
  • 评测
  • 测评结果:WA
  • 用时:2546ms
  • 内存:65080kb
  • [2024-01-12 09:56:20]
  • 提交

answer

#include<bits/stdc++.h>
#define X int x
#define LR int L,int R
#define m (L+R>>1)
#define LL x<<1,L,m
#define RR x<<1|1,m+1,R
#define V tr[x].v
#define S 20
#define N 200005
#define M 525252
#define uint unsigned
#define iv inline void
using namespace std;
int n,q,a[N],len[M];uint tg[M],C[N][S],pw[S],ans;
struct Seg{uint v[S];Seg(){fill(v,v+S,0);}
	friend Seg operator+(const Seg&a,const Seg&b){Seg r;
		for(int i=0;i<S;i++)for(int j=0;j<S-i;j++)
			r.v[i+j]+=a.v[i]*b.v[j];return r;}}tr[M],qv;
iv pu(X){tr[x]=tr[x<<1]+tr[x<<1|1];}
iv pt(X,int w,int F=1){tg[x]+=w;
	if(F){pw[0]=1;for(int i=1;i<S;i++)pw[i]=pw[i-1]*w;}
	for(int i=S-1;i>=0;i--)for(int j=0;j<i;j++)
		V[i]+=V[j]*C[len[x]-j][i-j]*pw[i-j];}
iv pd(X){if(tg[x])pt(x<<1,tg[x],1),pt(x<<1|1,tg[x]),tg[x]=0;}
iv bd(X,LR){len[x]=R-L+1;if(L==R)V[0]=1,V[1]=a[L];
	else bd(LL),bd(RR),pu(x);}
iv ud(X,LR,int l,int r,int w){if(l<=L&&R<=r){pt(x,w,1);return;}
	pd(x);if(l<=m)ud(LL,l,r,w);if(m<r)ud(RR,l,r,w);pu(x);}
inline Seg qr(X,LR,int l,int r){if(l<=L&&R<=r)return tr[x];pd(x);
	if(r<=m)return qr(LL,l,r);if(l>m)return qr(RR,l,r);
	return qr(LL,l,r)+qr(RR,l,r);}
inline int read(){
	int x=0,t=1;char ch=getchar();
	while(ch<'0'||'9'<ch){if(ch=='-')t=-1;ch=getchar();}
	while('0'<=ch&&ch<='9')x=x*10+(ch-'0'),ch=getchar();
	return x*t;}
iv write(int x){if(x<0)putchar('-'),x=-x;
	if(x>=10)write(x/10);putchar(x%10+'0');}
int main(){n=read(),q=read();
	for(int i=0;i<=n;C[i][0]=1,i++)
		for(int j=1;j<=min(i,S);j++)C[i][j]=C[i-1][j-1]+C[i-1][j];
	for(int i=1;i<=n;i++)a[i]=read()-1;bd(1,1,n);
	for(int qq=1,o,l,r,w;qq<=q;qq++){o=read(),l=read(),r=read(),ans=0;
		if(o==1)w=read(),ud(1,1,n,l,r,w);else{qv=qr(1,1,n,l,r);
			for(int i=0;i<S;i++)ans+=qv.v[i];write(ans&1048575),
			putchar('\n');}}
	return 0;
}

詳細信息

Test #1:

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

input:

10 10
969575 741825 24903 1047319 450475 256145 1045323 479255 810659 768323
1 5 6 3034
2 1 10
2 1 9
2 1 4
1 3 6 126904
2 5 5
2 9 9
1 7 7 853094
1 4 9 1025178
2 5 8

output:

1045541
1012343
558151
580413
810659
527353

result:

ok 6 lines

Test #2:

score: -100
Wrong Answer
time: 2546ms
memory: 65080kb

input:

200000 200000
496015 180543 330721 874799 740427 144379 598057 795949 323465 87657 683935 748203 748665 288301 846003 33033 746029 132621 876629 361899 701297 373189 256151 723161 377571 54947 91151 855991 433965 73347 155081 314317 790527 705555 1035217 298963 604641 203865 230029 802437 720769 843...

output:

746709
204215
115495
742121
598361
405501
618999
763763
205533
3673
216267
172361
684811
467671
211733
1027591
763759
121599
824455
95059
35879
952575
545017
1039275
366721
146399
888645
178395
975261
418125
667687
335543
685669
492433
267017
288627
1011143
621767
776185
956033
133791
200885
654021
...

result:

wrong answer 2nd lines differ - expected: '564663', found: '204215'