QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#284488#4260. 胡策的数列lgvc0 0ms0kbC++142.9kb2023-12-16 13:39:512023-12-16 13:39:51

Judging History

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

  • [2023-12-16 13:39:51]
  • 评测
  • 测评结果:0
  • 用时:0ms
  • 内存:0kb
  • [2023-12-16 13:39:51]
  • 提交

answer

//这回只花了114514min就打完了。
//真好。记得多手造几组。
#include <bits/stdc++.h>
//#define int long long
#define pai 3.141592653589793238462643383279502884197169399375105820
#define MOD 1000000007
#define eps 0.00000001
inline int min(int a,int b) {return a<b?a:b;}
inline int max(int a,int b) {return a>b?a:b;}
#define ULL unsigned long long
#define LL long long
#define INF 0x3f3f3f3f
#define INF_LL 0x3f3f3f3f3f3f3f3f
static char buf[1000000],*paa=buf,*pd=buf;
static char buf2[1000000],*pp=buf2;
#define getchar() paa==pd&&(pd=(paa=buf)+fread(buf,1,1000000,stdin),paa==pd)?EOF:*paa++
inline void pc(char ch){
	if(pp-buf2==1000000) fwrite(buf2,1,1000000,stdout),pp=buf2;
	*pp++=ch;
}
inline void pcc(){
	fwrite(buf2,1,pp-buf2,stdout);
	pp=buf2;
}
inline int read(void) {
	int w=1;
	register int x(0);register char c(getchar());
	while(c<'0'||c>'9') {if(c=='-') w=-1;c=getchar();}
	while(c>='0'&&c<='9') x=(x<<1)+(x<<3)+(c^48),c=getchar();
	return w*x;
}
void write(int x) {
	if(x<0) pc('-'),x=-x;
	static int sta[20];
	int top=0;
	do {
		sta[top++]=x%10,x/=10;
	} while(x);
	while(top) pc(sta[--top]+48);
}
void we(int x) {
	write(x);
	pc('\n');
}
inline bool cmp_xi(int a,int b) {return a<b;}
inline bool cmp_da(int a,int b) {return a>b;}
#define MOD 1000000009
int N,M,rt,nc,su[2000009],k,laz[2000009],ls[2000009],rs[2000009];
inline int pw(int a,int b) {
	int as=1;
	while(b) {
		if(b&1) as=1ll*as*a%MOD;
		a=1ll*a*a%MOD;
		b>>=1;
	}
	return as;
}
inline int ni(int a) {
	return pw(a,MOD-2);
}
#define md ((l+r)>>1)
void up(int& n,int l,int r,int L,int R,int v) {
	if(!n) n=++k;
	assert(k<=2000000);
	if(L<=l&&r<=R) {
		v=1ll*v*pw(nc,l-L)%MOD;
		laz[n]=v;
		su[n]=1ll*v*(pw(nc,r-l+1)-1)%MOD*ni(nc-1)%MOD;
		return; 
	}
	if(laz[n]!=-1) {
		if(!ls[n]) ls[n]=++k;
		if(!rs[n]) rs[n]=++k;assert(k<=2000000);
		laz[ls[n]]=laz[rs[n]]=laz[n];
		su[ls[n]]=1ll*laz[n]*(pw(nc,md-l+1)-1)%MOD*ni(nc-1)%MOD;
		su[rs[n]]=(su[n]-su[ls[n]]+MOD)%MOD;
		laz[n]=-1; 
	}
	if(md>=L) {
		up(ls[n],l,md,L,R,v);
	}
	if(R>md) {
		up(rs[n],md+1,r,L,R,v);
	}
	su[n]=(su[ls[n]]+su[rs[n]])%MOD;
}
int q(int n,int l,int r,int L,int R) {
	if(!n) return 0;
	if(L<=l&&r<=R) {
		return su[n];
	}
	if(laz[n]!=-1) {
		int x=std::max(l,L)-l,y=std::min(r,R)-l;
		return 1ll*pw(nc,x)*laz[n]%MOD*(pw(nc,y-x+1)-1)%MOD*ni(nc-1)%MOD; 
	}
	int as=0;
	if(md>=L) as=(as+q(ls[n],l,md,L,R))%MOD;
	if(R>md) as=(as+q(rs[n],md+1,r,L,R))%MOD;
	return as;
}
signed main(void) {
    //freopen("m.in","r",stdin);
    //freopen("m.out","w",stdout);
    memset(laz,-1,sizeof(laz));
    N=read();M=read();
    nc=2ll*ni(5)%MOD;
    int la=0;
    while(M--) {
    	int t=read();
    	if(t==1) {
    		int l=read()^la,r=read()^la,t=read(),p=read();
    		t=1ll*t*pw(nc,p)%MOD;
    		up(rt,1,N,l,r,t);
		} else {
			int l=read()^la,r=read()^la;
			la=q(rt,1,N,l,r);
			printf("%d\n",la);
		}
	}
    return 0; 
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Memory Limit Exceeded

input:

1000 1000
2 384 887
2 794 916
2 387 493
2 363 422
2 60 691
1 541 927 173 737
2 212 369
1 430 783 863 124
2 68 136
1 23 803 70 168
2 394 457
2 56242175 56241970
1 18045698 18045244 538 199
1 18045848 18045921 414 527
1 18045688 18045297 874 863
2 18045455 18045249
1 880171240 880171588 328 337
2 8801...

output:


result:


Test #2:

score: 0
Memory Limit Exceeded

input:

1000 1000
1 823 873 158 482
2 567 746
1 542 593 459 839
1 217 586 540 193
2 84 173
1 833 873 243 807
1 92 483 51 919
1 410 923 919 756
1 246 485 190 379
1 648 980 565 216
2 456 994
2 65959875 65959002
2 773846455 773846965
1 191311586 191311528 987 557
2 191311287 191310944
2 22407670 22407911
1 472...

output:


result:


Test #3:

score: 0
Memory Limit Exceeded

input:

30000 30000
2 887 29384
2 7794 16916
2 493 5387
2 12363 21422
2 8691 20060
1 541 23927 304089173 303455737
2 15369 25212
1 237797251 237787962 278722863 233665124
2 237786573 237779097
1 703548462 703532674 369133070 125898168
2 703561627 703534528
2 377940594 377938319
1 93626610 93621148 756898538...

output:


result:


Test #4:

score: 0
Memory Limit Exceeded

input:

30000 30000
2 5821 16155
2 21156 25068
1 944 24742 977572053 94719788
1 8410 21903 677519484 967968374
1 17136 21048 16957465 121199415
2 6461 25814
2 114355083 114358883
2 823991500 824016441
1 762415120 762423172 330946912 441374400
1 762415309 762438009 369862417 319360390
1 762421378 762444477 4...

output:


result:


Test #5:

score: 0
Memory Limit Exceeded

input:

30000 30000
1 11672 21190 182524338 341458088
1 23094 27178 936382447 89409995
2 8968 16814
1 447005802 446999706 239551406 220913531
1 447009545 446996469 247978260 192448686
1 447013567 446994681 514619010 997375262
1 447010954 447015996 137285127 152638542
1 447007818 447013331 225505930 19995890...

output:


result:


Test #6:

score: 0
Time Limit Exceeded

input:

1000000000 100000
1 165084912 560398153 114562054 7946614
1 513316289 709627600 692684682 9563221
1 151772576 940696860 889928665 277940
2 516574848 908637016
2 697674775 464569011
2 62680191 706401562
2 818225483 971242722
1 340438947 714758124 367958170 7698954
1 223526674 20218074 523602081 64750...

output:


result:


Test #7:

score: 0
Memory Limit Exceeded

input:

1000000000 100000
2 321770517 672581096
1 226562689 229475348 350357621 3604885
1 589424486 634776553 1904202 608903
2 215478793 496636707
2 833999414 997049963
2 945104982 298718780
1 461246959 781776053 974089684 5310027
2 815390949 933919213
2 770622914 514835494
2 25389709 385935935
2 27135093 7...

output:


result:


Test #8:

score: 0
Time Limit Exceeded

input:

1000000000 100000
2 460261625 925796893
1 584753743 898648885 265360960 161653620
1 105613561 961699382 901990208 407847025
1 3961667 834186672 874747354 904671659
2 26040530 339508690
2 51577036 809441626
1 469425687 683003902 661914301 68789242
2 409198322 392777413
2 83531507 392936481
2 80892178...

output:


result:


Test #9:

score: 0
Time Limit Exceeded

input:

1000000000 100000
2 410193210 625780412
2 484091042 766471904
2 242778609 266666348
2 369337484 504172986
2 251064700 747420962
1 506442375 857569106 831720664 971642389
2 106119119 757690602
1 730229206 168522714 349281888 403980853
1 1060677836 42772911 2369067 921630284
1 669040424 984529296 6105...

output:


result:


Test #10:

score: 0
Time Limit Exceeded

input:

1000000000 100000
2 948833365 967646174
2 678378654 699920239
1 528186592 724233230 659619398 100407090
2 434002148 477729496
1 125929935 858751315 638568830 420308079
1 253095689 815238031 780603257 802330740
1 223711150 450609527 597730182 864164468
2 847533935 943338342
1 268297717 321161318 3159...

output:


result: