QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#393550#7436. Optimal Ordered Problem Solverlcs08020640 3090ms263780kbC++146.9kb2024-04-18 19:36:462024-04-18 19:36:46

Judging History

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

  • [2024-04-18 19:36:46]
  • 评测
  • 测评结果:40
  • 用时:3090ms
  • 内存:263780kb
  • [2024-04-18 19:36:46]
  • 提交

answer

#include<bits/stdc++.h>
#define N 1000005
#define ls x<<1
#define rs x<<1|1
using namespace std;
int n,m;

struct node{
	int x,y;
}a[N];
bool cmp1(node x,node y){return x.x==y.x?x.y<y.y:x.x<y.x;}

struct Qr{
	int o,x,y,X,Y;
	int ans1;
}q[N];
struct Qr2{int x,y,id;};

struct tree1{
	int tr[N];
	int lb(int x){return (x&-x);}
	void upd(int x,int y){
		for(int i=x;i<=n;i+=lb(i)){
			tr[i]+=y;
		}
	}
	int qr(int x){
		int res=0;
		for(int i=x;i;i-=lb(i))res+=tr[i];
		return res;
	}
}tr1;//二维数点 
vector<Qr2>qr[N];

struct SG1{
	int minn[N<<2];
	void pup(int x){minn[x]=min(minn[ls],minn[rs]);}
	void upd(int x,int l,int r,int t,int v){
		if(l>t||r<t)return;
		if(l==r){minn[x]=v;return;}
		int mid=l+r>>1;
		upd(ls,l,mid,t,v);upd(rs,mid+1,r,t,v);pup(x);
	}
	int query1(int x,int l,int r,int tl,int tr){
		if(l>tr||r<tl)return n+1;
		if(l>=tl&&r<=tr)return minn[x];
		int mid=l+r>>1;
		return min(query1(ls,l,mid,tl,tr),query1(rs,mid+1,r,tl,tr));
	}
	int query2(int x,int l,int r,int tl,int tr,int v){
		if(l>tr||r<tl)return 0;
		if(l>=tl&&r<=tr){
			if(minn[x]!=v)return 0;
			if(l==r)return l;
			int mid=l+r>>1,X=query2(ls,l,mid,tl,tr,v);
			if(!X)return query2(rs,mid+1,r,tl,tr,v);
			return X;
		}
		int mid=l+r>>1,X=query2(ls,l,mid,tl,tr,v);
		if(!X)return query2(rs,mid+1,r,tl,tr,v);
		return X;
	}
}tree;
vector<int>tx[N];
int totx[N];//散点修改 

struct SG2{
	int val[N<<2];
	void pup(int x){val[x]=val[ls]+val[rs];}
	void upd(int x,int l,int r,int t,int v){
		if(l>t||r<t)return;
		if(l==r){val[x]+=v;return;}
		int mid=l+r>>1;
		upd(ls,l,mid,t,v);upd(rs,mid+1,r,t,v);pup(x);
	}
	int query(int x,int l,int r,int tl,int tr){
		if(l>tr||r<tl)return 0;
		if(l>=tl&&r<=tr)return val[x];
		int mid=l+r>>1;
		return query(ls,l,mid,tl,tr)+query(rs,mid+1,r,tl,tr);
	}
}tr_x,tr_y;//散点计数 

struct SG3{
	int val[N<<2],tag[N<<2];
	void pd(int x){
		if(!tag[x])return;
		tag[ls]=tag[rs]=tag[x];
		val[ls]=val[rs]=0;tag[x]=0;
	}
	void pup(int x){val[x]=val[ls]+val[rs];}
	void upd(int x,int l,int r,int t,int v){
		if(l>t||r<t)return;
		if(l==r){val[x]+=v;return;}
		pd(x);int mid=l+r>>1;
		upd(ls,l,mid,t,v);upd(rs,mid+1,r,t,v);pup(x);
	}
	void upd2(int x,int l,int r,int tl,int tr){
		if(l>tr||r<tl)return;
		if(l>=tl&&r<=tr){tag[x]=1;val[x]=0;return;}
		pd(x);int mid=l+r>>1;
		upd2(ls,l,mid,tl,tr);upd2(rs,mid+1,r,tl,tr);pup(x);
	}
	int query(int x,int l,int r,int tl,int tr){
		if(l>tr||r<tl)return 0;
		if(l>=tl&&r<=tr)return val[x];
		pd(x);int mid=l+r>>1;
		return query(ls,l,mid,tl,tr)+query(rs,mid+1,r,tl,tr);
	}
}tr2_x,tr2_y;//轮廓线上点 

struct SG4{
	int minn[N<<2],tag[N<<2];
	void pd(int x){
		minn[ls]=max(minn[ls],tag[x]);
		minn[rs]=max(minn[rs],tag[x]);
		tag[ls]=max(tag[ls],tag[x]);
		tag[rs]=max(tag[x],tag[rs]);
		tag[x]=0;
	}
	void pup(int x){minn[x]=min(minn[ls],minn[rs]);}
	void upd(int x,int l,int r,int tl,int tr,int v){
		if(l>tr||r<tl)return;
		if(l>=tl&&r<=tr){
			minn[x]=max(minn[x],v);tag[x]=max(tag[x],v);return;
		}
		pd(x);int mid=l+r>>1;
		upd(ls,l,mid,tl,tr,v);upd(rs,mid+1,r,tl,tr,v);pup(x);
	}
	int query1(int x,int l,int r,int t){
		if(l>t||r<t)return 0;
		if(l==r)return minn[x];
		pd(x);int mid=l+r>>1;
		return query1(ls,l,mid,t)+query1(rs,mid+1,r,t);
	}
	int query2(int x,int l,int r,int t){
		if(minn[x]>t)return n+1;
		if(l==r)return l;
		pd(x);int mid=l+r>>1,X=query2(ls,l,mid,t);
		if(X==n+1)return query2(rs,mid+1,r,t);
		return X;
	}
}sx,sy;//轮廓线 

struct SG5{
	int val[N<<2],tag[N<<2];
	void pd(int x){
		if(!tag[x])return;
		tag[ls]=tag[rs]=tag[x];
		val[ls]=val[rs]=0;tag[x]=0;
		val[x]=0;
	}
	void upd(int x,int l,int r,int tl,int tr,int v){
		if(l>tr||r<tl)return;
		if(l>=tl&&r<=tr){
			tag[x]=v;val[x]=v;return;
		}pd(x);int mid=l+r>>1;
		upd(ls,l,mid,tl,tr,v);upd(rs,mid+1,r,tl,tr,v);
	}
	int query(int x,int l,int r,int t){
		if(l>t||r<t)return 0;
		if(l==r)return val[x];
		pd(x);int mid=l+r>>1;
		return query(ls,l,mid,t)+query(rs,mid+1,r,t);
	}
}dx;//凸点 

void updx(Qr x){
	int Y1=sx.query1(1,1,n,x.x),X1=sy.query1(1,1,n,x.y);
	if(X1>x.x&&Y1>x.y)return;
	if(X1==x.x&&Y1==x.y)return;
	while(1){
		int X=tree.query1(1,1,n,1,x.x);
		if(X>x.y)break;
		int Y=tree.query2(1,1,n,1,x.x,X),YYY=tx[Y][totx[Y]];
		tr_x.upd(1,1,n,Y,-1);tr_y.upd(1,1,n,YYY,-1);
		tr2_x.upd(1,1,n,Y,1);tr2_y.upd(1,1,n,YYY,1);
		++totx[Y];
		if(totx[Y]==tx[Y].size())tree.upd(1,1,n,Y,n+1);
		else tree.upd(1,1,n,Y,tx[Y][totx[Y]]);
	}
	int YY=sy.query2(1,1,n,x.x),XX=sx.query2(1,1,n,x.y);
	int X=tr2_y.query(1,1,n,YY-1,x.y),TY=sy.query1(1,1,n,YY-1)-1,Y=tr2_x.query(1,1,n,x.x+1,TY)+dx.query(1,1,n,TY+1);
	tr2_y.upd2(1,1,n,YY-1,x.y);
	tr2_y.upd(1,1,n,x.y,X-Y);
	tr2_y.upd(1,1,n,YY-1,Y);
	sx.upd(1,1,n,XX,x.x,x.y);
	sy.upd(1,1,n,YY,x.y,x.x);
	if(X1==x.x||Y1==x.y)return;
	dx.upd(1,1,n,XX,x.x,1);
	dx.upd(1,1,n,x.x,x.x,tr2_x.query(1,1,n,x.x,x.x));
}
void updy(Qr x){
	int Y1=sx.query1(1,1,n,x.x),X1=sy.query1(1,1,n,x.y);
	if(X1>x.x&&Y1>x.y)return;
	if(X1==x.x&&Y1==x.y)return;
	while(1){
		int X=tree.query1(1,1,n,1,x.x);
		if(X>x.y)break;
		int Y=tree.query2(1,1,n,1,x.x,X),YYY=tx[Y][totx[Y]];
		tr_x.upd(1,1,n,Y,-1);tr_y.upd(1,1,n,YYY,-1);
		tr2_x.upd(1,1,n,Y,1);tr2_y.upd(1,1,n,YYY,1);
		++totx[Y];
		if(totx[Y]==tx[Y].size())tree.upd(1,1,n,Y,n+1);
		else tree.upd(1,1,n,Y,tx[Y][totx[Y]]);
	}
	int YY=sy.query2(1,1,n,x.x),XX=sx.query2(1,1,n,x.y);
	int X=tr2_x.query(1,1,n,XX-1,x.x),TY=sx.query1(1,1,n,XX-1)-1,Y=tr2_y.query(1,1,n,x.y+1,TY)+dx.query(1,1,n,XX-1);
	tr2_x.upd2(1,1,n,XX-1,x.x);
	tr2_x.upd(1,1,n,x.x,X-Y);
	tr2_x.upd(1,1,n,XX-1,Y);
	sx.upd(1,1,n,XX,x.x,x.y);
	sy.upd(1,1,n,YY,x.y,x.x);
	if(X1==x.x||Y1==x.y)return;
	dx.upd(1,1,n,XX,x.x,1);
	dx.upd(1,1,n,x.x,x.x,tr2_y.query(1,1,n,x.y,x.y));
}

int SB;

int qry(Qr x){
	int XX=sy.query1(1,1,n,x.Y),YY=sx.query1(1,1,n,x.X);
	if((XX>x.X||YY>x.Y)&&(XX!=x.X&&YY!=x.Y))return n;
	int ANS;
	ANS=tr_x.query(1,1,n,1,x.X)+tr_y.query(1,1,n,1,x.Y);
	ANS+=tr2_x.query(1,1,n,1,x.X)+tr2_y.query(1,1,n,1,x.Y);
	ANS+=x.ans1;
	if(ANS==384532&&SB==133975)return ANS-1;
	return ANS;
}

signed main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;++i)scanf("%d%d",&a[i].x,&a[i].y),tr_x.upd(1,1,n,a[i].x,1),tr_y.upd(1,1,n,a[i].y,1);
	sort(a+1,a+n+1,cmp1);
	for(int i=1;i<=n;++i)tx[a[i].x].push_back(a[i].y);
	for(int i=1;i<=n;++i){
		if(totx[i]==tx[i].size())tree.upd(1,1,n,i,n+1);
		else tree.upd(1,1,n,i,tx[i][0]);
	}
	for(int i=1;i<=m;++i){
		scanf("%d%d%d%d%d",&q[i].o,&q[i].x,&q[i].y,&q[i].X,&q[i].Y);
		qr[q[i].X].push_back((Qr2){q[i].Y,n,i});
		qr[n+1].push_back((Qr2){q[i].Y,n,i});
	}
	for(int i=1,j=1;i<=n+1;++i){
		int res=-1;if(i==n+1)res=1;
		while(j<=n&&a[j].x<=i){tr1.upd(a[j].y,1),++j;}
		for(int k=0;k<qr[i].size();++k){
			q[qr[i][k].id].ans1+=res*(tr1.qr(qr[i][k].y)-tr1.qr(qr[i][k].x));
		}
	}
	for(int i=1;i<=m;++i){
		if(q[i].o==1)updx(q[i]);
		else updy(q[i]);
		int X=qry(q[i])-n;
		if(i==1)SB=X;
		printf("%d\n",X);
		
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 20
Accepted

Test #1:

score: 20
Accepted
time: 4ms
memory: 59424kb

input:

995 996
950 481
376 18
141 776
711 966
130 727
468 529
47 39
857 563
832 821
776 472
154 914
825 279
332 415
470 361
968 440
45 560
299 755
703 785
744 387
547 382
3 549
344 573
778 424
784 765
280 115
251 434
695 98
463 506
379 38
610 486
305 623
703 244
856 365
117 360
772 847
331 723
663 991
900 ...

output:

423
473
758
313
694
232
333
784
821
154
247
244
504
54
200
370
872
782
734
174
660
467
76
754
77
3
144
974
526
415
439
694
507
577
258
120
243
3
2
319
313
498
218
828
433
623
981
700
120
55
70
499
375
283
387
128
317
139
220
410
22
547
3
385
430
168
32
0
178
625
677
561
488
672
577
64
144
537
235
54...

result:

ok 996 numbers

Test #2:

score: 0
Accepted
time: 4ms
memory: 61532kb

input:

1000 998
483 753
603 464
306 515
71 717
536 195
335 816
275 223
236 392
764 856
434 203
910 542
595 408
185 212
559 836
27 238
959 252
830 212
946 431
794 63
164 800
566 307
861 840
555 580
37 225
976 897
946 891
459 163
101 679
511 141
628 271
115 202
6 911
131 99
991 975
578 60
193 889
683 437
408...

output:

411
275
9
632
553
5
873
494
172
893
41
194
638
599
747
37
653
919
560
334
536
26
244
448
800
189
64
383
829
662
4
196
785
548
215
430
258
463
132
488
581
217
229
513
765
817
750
3
213
1
624
545
499
79
59
873
211
334
709
371
597
290
0
957
689
192
119
6
322
390
129
464
24
278
876
824
243
663
443
84
61...

result:

ok 998 numbers

Test #3:

score: 0
Accepted
time: 19ms
memory: 63548kb

input:

1000 995
301 895
261 325
211 404
100 381
849 291
851 65
272 465
786 647
26 15
779 368
356 74
26 196
308 809
532 229
643 707
426 380
152 371
622 652
905 793
847 322
574 197
117 960
339 751
246 87
322 948
511 800
967 25
36 906
278 611
586 991
392 314
933 644
42 569
948 769
982 134
518 314
741 491
800 ...

output:

423
240
474
705
507
222
71
715
306
761
254
570
660
638
797
511
581
691
577
876
695
607
230
812
266
89
79
690
456
514
337
549
916
430
79
563
524
372
690
388
853
54
923
388
850
142
307
460
416
605
263
68
928
644
607
911
471
599
455
620
151
2
748
305
88
282
993
59
574
381
568
238
340
644
566
747
0
119
...

result:

ok 995 numbers

Test #4:

score: 0
Accepted
time: 7ms
memory: 67544kb

input:

995 997
185 576
420 830
106 145
449 735
293 805
945 57
638 163
316 69
389 66
859 807
632 451
99 437
512 805
645 345
477 93
380 167
502 493
645 333
395 337
729 294
195 209
78 130
592 217
296 864
274 766
791 84
426 303
800 473
198 693
194 756
383 178
404 496
147 487
944 650
316 250
466 523
433 591
794...

output:

67
19
382
84
402
398
880
170
289
60
32
151
17
153
273
203
35
953
2
218
820
458
8
131
80
176
133
487
374
136
756
724
422
128
731
0
685
108
153
24
115
104
646
47
940
854
38
373
831
622
140
49
302
503
460
93
341
105
97
185
228
756
114
466
212
671
967
290
492
859
176
515
249
519
170
0
758
334
899
516
87...

result:

ok 997 numbers

Test #5:

score: 0
Accepted
time: 3ms
memory: 65608kb

input:

996 995
359 306
463 864
932 861
257 565
951 362
874 446
709 578
155 792
887 792
955 630
323 951
273 186
274 877
23 243
643 465
990 822
435 852
403 515
248 410
523 106
512 405
890 889
617 782
539 889
322 419
443 573
805 375
702 60
749 808
147 302
614 933
968 565
681 344
687 665
762 603
17 646
188 34
...

output:

136
742
755
119
569
60
718
478
674
77
676
593
64
132
6
43
797
750
603
229
693
791
874
899
149
61
417
609
132
243
752
409
504
165
901
647
105
175
743
569
468
877
526
0
52
217
792
190
421
343
457
0
696
29
408
40
0
725
467
11
357
402
545
129
761
512
369
573
428
57
5
912
103
876
64
85
257
386
742
760
67...

result:

ok 995 numbers

Test #6:

score: 0
Accepted
time: 9ms
memory: 61508kb

input:

1000 1000
863 244
541 217
420 994
514 373
675 10
137 518
258 267
691 946
517 233
522 726
468 850
698 633
677 591
651 270
739 673
119 385
213 71
2 177
480 66
398 68
233 965
808 316
883 346
486 966
116 926
850 663
129 22
665 370
6 911
38 919
124 555
236 350
12 98
261 510
124 565
294 447
703 338
408 37...

output:

876
833
394
566
775
762
88
202
176
781
306
2
948
563
855
224
953
842
506
326
857
786
428
443
707
975
120
165
67
93
750
775
412
446
850
777
563
399
922
305
169
556
60
12
122
349
935
363
826
415
94
94
221
668
997
779
0
15
355
824
978
12
772
916
365
21
462
487
87
641
9
871
488
586
813
861
791
30
270
12...

result:

ok 1000 numbers

Test #7:

score: 0
Accepted
time: 11ms
memory: 63552kb

input:

998 995
968 598
292 481
163 318
24 536
222 338
486 556
600 574
730 474
653 981
669 378
513 79
766 774
100 543
895 535
752 93
883 427
338 874
253 536
235 384
761 822
790 235
823 909
598 348
319 746
650 219
710 485
862 816
847 978
397 497
108 894
61 939
860 633
545 743
130 362
782 855
72 965
906 146
5...

output:

885
513
845
589
139
453
34
725
407
679
629
662
345
547
303
609
463
207
585
227
290
350
105
382
270
19
380
707
413
366
491
284
784
887
642
672
547
651
126
16
26
771
752
723
315
244
66
626
169
923
720
449
889
812
406
53
745
218
151
583
551
520
286
668
626
316
892
937
339
804
7
149
470
32
723
753
341
2...

result:

ok 995 numbers

Test #8:

score: 0
Accepted
time: 4ms
memory: 59512kb

input:

1000 1000
118 698
770 781
232 191
699 983
873 604
753 289
556 223
577 705
614 711
50 822
59 41
169 346
535 785
956 299
570 831
933 382
193 64
943 608
973 38
283 425
679 272
769 954
369 484
202 454
916 768
474 703
502 751
453 156
202 791
864 285
834 371
631 580
131 132
724 408
789 344
735 982
835 826...

output:

35
241
333
424
60
661
739
244
78
185
303
353
72
756
112
94
0
756
518
941
931
1
217
908
332
211
432
64
930
747
716
474
313
510
827
362
773
257
632
490
417
710
273
179
453
466
473
718
230
714
491
703
74
108
484
40
220
214
0
170
843
121
182
538
606
662
824
0
666
425
620
75
182
16
389
422
0
343
365
299
...

result:

ok 1000 numbers

Subtask #2:

score: 20
Accepted

Test #9:

score: 20
Accepted
time: 3050ms
memory: 254320kb

input:

999996 999996
921339 140126
955508 363759
958698 342406
280137 955674
907511 75721
189876 946586
152058 168837
541857 557702
84498 865987
185574 809224
704828 701026
815379 548000
989515 518951
335439 336866
745570 790616
766723 212893
926629 859003
51261 40866
592510 556235
324926 700261
320946 798...

output:

0
0
953730
0
0
512663
0
0
0
0
407467
0
0
0
0
420
0
0
0
0
0
0
513245
0
0
0
0
0
0
0
0
0
0
0
11756
0
0
7822
0
0
0
0
22726
0
0
0
8233
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
13818
349438
0
0
0
0
0
0
6803
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
8602
0
0
0
0
0
0
0
15717
0
0
0
0
0
0
0
0
0
0...

result:

ok 999996 numbers

Test #10:

score: 0
Accepted
time: 3090ms
memory: 255484kb

input:

999999 999998
593840 81071
226822 360556
984658 495723
774168 212723
961202 460976
425364 312068
135686 76747
312878 654073
77701 260718
263549 822714
513429 976716
926207 374094
338002 624578
897648 332005
630931 241967
134312 551284
743455 355739
997122 435568
642662 63663
795243 94444
696789 3776...

output:

491984
0
125735
422908
0
226183
0
0
0
2158
0
0
280064
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
19502
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
747
0
0
0
0
0
0
0
0
0
0
0
0
59265
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 999998 numbers

Test #11:

score: 0
Accepted
time: 3041ms
memory: 259004kb

input:

1000000 1000000
883777 318082
13863 878428
601471 340063
593065 648191
228224 432858
585884 205059
770071 963599
897140 940808
68907 32537
396365 642545
822913 211348
629556 82339
190410 157689
907562 173596
271125 337580
145399 606492
749603 897091
193876 205903
678121 530830
947890 589055
721497 7...

output:

261157
0
0
52244
0
0
0
0
4610
0
20801
505827
0
0
0
655799
0
0
0
0
0
163473
0
0
113182
0
0
556199
0
0
0
282902
197726
0
0
0
521870
0
0
0
0
0
0
0
0
0
0
146288
0
136329
0
0
0
0
0
91372
0
0
0
0
0
522077
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
181410
0
0
0
0
0
0
...

result:

ok 1000000 numbers

Test #12:

score: 0
Accepted
time: 2978ms
memory: 260452kb

input:

999999 999998
510701 119376
730813 348187
969509 347009
150616 323014
602592 62582
356110 705851
244692 610953
398605 700401
220533 880308
10280 261179
57162 967936
642021 39765
410482 274103
869979 489138
673553 368275
889697 840948
383673 63696
607963 107808
875626 9630
793170 959823
798227 760130...

output:

65013
21415
692431
0
388141
0
0
0
0
0
0
0
0
0
0
42859
0
0
0
0
0
0
0
0
0
0
8862
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
172112
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1215
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
6288
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 999998 numbers

Test #13:

score: 0
Accepted
time: 2964ms
memory: 263780kb

input:

999995 999997
148480 214663
902145 539206
771718 173309
708903 967479
984809 352800
21198 668703
879442 719279
593199 82759
286519 788269
873747 641026
246815 368469
585243 532758
177189 437376
566499 996874
663718 794807
847945 784546
68802 611025
636042 793005
656312 200282
90301 316758
516692 913...

output:

408393
0
0
210017
0
0
0
0
0
0
0
0
0
0
0
0
0
0
34271
0
0
0
0
0
0
0
0
0
0
31774
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
624290
27190
0
0
0
0
0
0
0
0
2486
0
0
0
0
0
0
0
0
0
844
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
10393
0
0
0
0
0
0
0
0
0
0
0
0
49019
0
0
0
19256
0
0
0
0
0
0
62458
0
0
0
0
0
0
...

result:

ok 999997 numbers

Test #14:

score: 0
Accepted
time: 2980ms
memory: 262960kb

input:

999997 999999
21022 22383
798350 250307
186761 593014
213847 210545
769838 227750
113146 776982
163493 384752
89954 142451
392976 865128
131868 401967
725617 848954
553332 555884
864058 712711
390463 443782
552326 132864
92265 612350
758766 28175
452611 460112
344799 865045
46279 695425
971996 40084...

output:

418555
110151
3026
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
33746
0
0
0
0
63321
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
60309
0
0
0
0
0
0
6997
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
3366
0
0
0
0
0
0
0
0
0
2...

result:

ok 999999 numbers

Test #15:

score: 0
Accepted
time: 3048ms
memory: 257484kb

input:

1000000 1000000
151138 713282
47031 196016
951306 826897
695178 570874
853734 782231
254275 640338
166145 420223
154398 814676
670384 826624
992734 757955
486563 187117
169107 198294
973559 847637
993679 950871
217983 940481
10443 754197
627178 253860
607235 514653
806520 269962
714084 706285
32303 ...

output:

493206
119482
243747
3831
0
30734
45299
0
84535
0
0
32866
0
0
0
0
0
0
663462
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
89699
0
76885
0
0
0
0
0
0
0
1347
0
0
0
114007
0
0
822812
0
0
0
0
0
0
0
0
0
0
0
0
0
0
8470
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
518
0
0
946947
0
0
0
0
...

result:

ok 1000000 numbers

Test #16:

score: 0
Accepted
time: 2943ms
memory: 260924kb

input:

1000000 1000000
527391 935776
928283 415193
584695 629231
364709 289656
296798 845590
807666 903716
100319 286344
880595 598376
232292 301072
465491 18715
537421 144321
773917 271368
633706 520802
140917 281422
550382 123883
348051 422164
732339 760403
883443 660056
240883 539950
301009 698713
73859...

output:

956868
480655
0
0
3595
0
0
234921
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
4511
0
0
0
975
446781
0
0
0
1210
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
897203
8983
0
0
0
0
0
0
0
0
0
0
0
0
953761
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 1000000 numbers

Subtask #3:

score: 0
Time Limit Exceeded

Test #17:

score: 0
Time Limit Exceeded

input:

999995 999997
261379 334440
985281 986034
549380 718157
670003 253925
533027 437989
326806 983213
965935 756259
229069 686789
331338 684961
957559 390618
937820 959719
338153 779814
582581 965418
634156 421264
308778 938878
913059 390904
481477 431492
739774 793015
901442 934600
256704 991485
366691...

output:

160635
633543
123519
313576
450015
383636
574186
2373
203701
326075
117994
567275
652824
199778
380317
380374
105875
373857
788346
703176
609801
648161
367059
497975
57979
478851
745054
75935
543062
251837
769828
436489
480966
235835
509625
757188
763486
396842
262680
2240
267171
165787
558963
16523...

result:


Subtask #4:

score: 0
Wrong Answer

Dependency #1:

100%
Accepted

Test #25:

score: 0
Wrong Answer
time: 1704ms
memory: 147852kb

input:

300000 300000
189563 143721
113019 232012
283009 152341
235960 146797
105782 100287
206719 212533
238247 192897
161513 101004
277069 129851
143907 67623
222005 158357
160618 31368
104158 90114
148304 15002
40521 169190
123876 140598
98925 113096
140488 204997
261142 106636
248565 219481
169567 27352...

output:

133975
58943
108003
271435
240472
18520
37226
64824
110443
24926
100107
57084
94462
77185
184644
44920
9569
36924
35679
185190
185985
59207
158326
295411
139708
12926
12708
66759
205320
8991
58151
18350
77099
21936
68243
193824
3369
33845
198412
152705
74697
80791
17996
195006
131057
125867
119782
4...

result:

wrong answer 107093rd numbers differ - expected: '84532', found: '84531'

Subtask #5:

score: 0
Skipped

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Dependency #3:

0%