QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#590732#8949. 赫露艾斯塔Xun_xiaoyao40 4662ms201784kbC++175.1kb2024-09-26 10:41:132024-09-26 10:41:13

Judging History

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

  • [2024-09-26 10:41:13]
  • 评测
  • 测评结果:40
  • 用时:4662ms
  • 内存:201784kb
  • [2024-09-26 10:41:13]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
int Qread()
{
	int x=0;char ch=getchar();
	while(ch<'0'||ch>'9') ch=getchar();
	while(ch>='0'&&ch<='9') x=x*10+(ch^48),ch=getchar();
	return x;
}
int n,m;
#define ls (pos<<1)
#define rs (pos<<1|1)
#define mid ((l+r)>>1)
namespace NSege{
	vector<int> nd[1000010];
	pair<int,int> s[4000010];
	inline void update(int pos){s[pos]=min(s[ls],s[rs]);}
	inline void sst(int pos,int x){s[pos]=make_pair(((!nd[x].empty())?*nd[x].rbegin():n+1),x);}
	void init(int pos=1,int l=1,int r=n)
	{
		if(l==r) sort(nd[l].begin(),nd[l].end(),greater<int>()),sst(pos,l);
		else init(ls,l,mid),init(rs,mid+1,r),update(pos);
	}
	void del(int x,int pos=1,int l=1,int r=n)
	{
		if(l==r) return nd[x].pop_back(),sst(pos,x);
		if(x<=mid) del(x,ls,l,mid),update(pos);
		else del(x,rs,mid+1,r),update(pos);
	}
	pair<int,int> range_mn(int L,int R,int pos=1,int l=1,int r=n)
	{
		if(L<=l&&r<=R) return s[pos];
		if(R<=mid) return range_mn(L,R,ls,l,mid);
		if(mid<L) return range_mn(L,R,rs,mid+1,r);
		return min(range_mn(L,R,ls,l,mid),range_mn(L,R,rs,mid+1,r));
	}
}
#undef ls
#undef rs
#undef mid
#define ls s[x].lson
#define rs s[x].rson
mt19937 zsh(20070610);
struct Node{
	int x,y,lson,rson;
	unsigned int key;
	int lazx,lazy,siz;
}s[1000010];
int poi_cnt;
inline int get_node(int x,int y)
{
	++poi_cnt;
	s[poi_cnt].x=x,s[poi_cnt].y=y,s[poi_cnt].siz=1;
	s[poi_cnt].key=zsh();
	return poi_cnt;
}
inline void update(int x){s[x].siz=s[ls].siz+s[rs].siz+1;}
inline void giv_lazx(int pos,int x){s[pos].x=s[pos].lazx=x;}
inline void giv_lazy(int pos,int y){s[pos].y=s[pos].lazy=y;}
inline void pushdown(int x)
{
	if(s[x].lazx) giv_lazx(ls,s[x].lazx),giv_lazx(rs,s[x].lazx),s[x].lazx=0;
	if(s[x].lazy) giv_lazy(ls,s[x].lazy),giv_lazy(rs,s[x].lazy),s[x].lazy=0;
}
int merge(int x,int y)
{
	if(x&&y)
	{
		if(s[x].key>s[y].key) return pushdown(x),s[x].rson=merge(s[x].rson,y),update(x),x;
		else return pushdown(y),s[y].lson=merge(x,s[y].lson),update(y),y;
	}
	else return x^y;
}
void split_x(int rt,int k,int &x,int &y)
{
	if(!rt) return x=y=0,void();
	pushdown(rt);
	if(s[rt].x<k) x=rt,split_x(s[rt].rson,k,s[x].rson,y),update(x);
	else y=rt,split_x(s[rt].lson,k,x,s[y].lson),update(y);
}
void split_y(int rt,int k,int &x,int &y)
{
	if(!rt) return x=y=0,void();
	pushdown(rt);
	if(s[rt].y>k) x=rt,split_y(s[rt].rson,k,s[x].rson,y),update(x);
	else y=rt,split_y(s[rt].lson,k,x,s[y].lson),update(y);
}
void split(int rt,int kx,int ky,int &x,int &y)
{
	if(!rt) return x=y=0,void();
	pushdown(rt);
	if(s[rt].x<kx||(s[rt].x==kx&&s[rt].y>ky)) x=rt,split(s[rt].rson,kx,ky,s[x].rson,y),update(x);
	else y=rt,split(s[rt].lson,kx,ky,x,s[y].lson),update(y);
}
void show(int x)
{
	if(!x) return;
	pushdown(x);
	show(ls),printf("(%d %d)",s[x].x,s[x].y),show(rs);
}
#undef ls
#undef rs

struct BIT{
	int num[1000010];
	inline void add(int x){x=n-x+1;for(;x<=n;x+=(x&-x)) num[x]++;}
	inline void del(int x){x=n-x+1;for(;x<=n;x+=(x&-x)) num[x]--;}
	inline int sum(int x){int ret=0;x=n-x+1;for(;x;x-=(x&-x)) ret+=num[x];return ret;}
}D1,D2,B;

typedef pair<int,int> pr;
bool o=true;
set<pr> S;set<pr>::iterator it,it_;
int x[1000010],y[1000010],op,x_,y_,X,Y;
int ans[1000010],lst;pr tmp;

vector<pr> qry[1000010];
vector<int> nd[1000010];

int main()
{
	n=Qread(),m=Qread();lst=n;
	for(int i=1;i<=n;i++)
	{
		x[i]=Qread(),y[i]=Qread();
		NSege::nd[x[i]].push_back(y[i]);nd[x[i]].push_back(y[i]);
		D1.add(x[i]),D2.add(y[i]);
	}
	NSege::init();
	S.insert(make_pair(-1,n+3)),S.insert(make_pair(n+3,-1));

	for(int i=1,p1,p2,p3,rt=0;i<=m;i++)
	{
		op=Qread(),x_=Qread(),y_=Qread(),X=Qread(),Y=Qread();

		it=S.lower_bound(make_pair(x_,0));
		if(y_>= it->second)
		{
			if(op==1)
			{
				split_x(rt,x_+1,p2,p3);
				split_y(p2,y_,p1,p2);

				giv_lazy(p2,y_);
				rt=merge(merge(p1,p2),p3);

				tmp=NSege::range_mn(1,x_);
				while(tmp.first<=y_)
				{
					lst--;
					NSege::del(tmp.second);
					
					split(rt,tmp.second,y_,p1,p2);
					rt=merge(merge(p1,get_node(tmp.second,y_)),p2);

					D1.del(tmp.second),D2.del(tmp.first);
					tmp=NSege::range_mn(1,x_);
				}
			}
			else
			{
				split_x(rt,x_+1,p2,p3);
				split_y(p2,y_,p1,p2);

				giv_lazx(p2,x_);
				rt=merge(merge(p1,p2),p3);

				tmp=NSege::range_mn(1,x_);
				while(tmp.first<=y_)
				{
					lst--;
					NSege::del(tmp.second);

					split(rt,x_,tmp.first,p1,p2);
					rt=merge(merge(p1,get_node(x_,tmp.first)),p2);
					
					D1.del(tmp.second),D2.del(tmp.first);
					tmp=NSege::range_mn(1,x_);
				}
			}

			it=S.upper_bound(make_pair(x_,y_));
			it--;
			while(it->second <=y_)
				it_=it,it--,S.erase(it_);
			S.insert(make_pair(x_,y_));
		}

		it=S.upper_bound(make_pair(X,n));
		if(Y< it->second) continue;

		ans[i]=lst;
		ans[i]-=D1.sum(X+1)+D2.sum(Y+1);

		split_x(rt,X+1,p2,p3);
		split_y(p2,Y,p1,p2);
		ans[i]+=s[p2].siz;
		rt=merge(merge(p1,p2),p3);
	
		qry[X].push_back(make_pair(Y+1,i));
	}

	for(int i=n;i;i--)
	{
		for(pr g:qry[i]) ans[g.second]+=B.sum(g.first);
		for(int g:nd[i]) B.add(g);
	}

	for(int i=1;i<=m;i++)
		printf("%d\n",ans[i]);
	return 0;
}

詳細信息

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 10
Accepted
time: 8ms
memory: 90476kb

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: 10
Accepted
time: 3ms
memory: 90520kb

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: 10
Accepted
time: 8ms
memory: 90528kb

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: 10
Accepted
time: 14ms
memory: 90564kb

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: 10
Accepted
time: 8ms
memory: 90632kb

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
Wrong Answer
time: 8ms
memory: 90520kb

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:

wrong answer 345th numbers differ - expected: '161', found: '189'

Subtask #2:

score: 20
Accepted

Test #9:

score: 20
Accepted
time: 1472ms
memory: 187376kb

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: 20
Accepted
time: 1289ms
memory: 187368kb

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: 20
Accepted
time: 1319ms
memory: 187440kb

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: 20
Accepted
time: 1546ms
memory: 185336kb

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: 20
Accepted
time: 1504ms
memory: 185372kb

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: 20
Accepted
time: 1568ms
memory: 187564kb

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: 20
Accepted
time: 1435ms
memory: 187400kb

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: 20
Accepted
time: 1413ms
memory: 187476kb

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: 20
Accepted

Test #17:

score: 20
Accepted
time: 3766ms
memory: 200916kb

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:

ok 999997 numbers

Test #18:

score: 20
Accepted
time: 2232ms
memory: 201672kb

input:

999995 1000000
503105 994319
301845 645636
538613 176453
944222 13642
220616 61270
445661 771824
758217 940994
11782 103262
159910 298805
317312 333018
741333 381578
579921 219986
605953 400913
625208 245340
729891 669648
186684 920562
118589 936228
281749 70955
103542 8281
854584 972667
663720 1425...

output:

8906
95485
8020
794529
288722
194571
738405
141163
47184
574675
21317
361918
336935
752285
747548
767325
485498
549919
836009
224230
243311
43089
166877
861403
1740
800031
757202
757248
571568
258896
110506
308599
111448
82706
495681
126271
557664
498332
507141
161535
251016
116433
490396
350530
854...

result:

ok 1000000 numbers

Test #19:

score: 20
Accepted
time: 4662ms
memory: 199592kb

input:

999997 1000000
44415 540937
815519 772048
580901 820033
176932 136598
26200 658165
495640 298186
350660 672003
66843 751311
886121 454924
75107 454946
855867 668594
952401 723257
914495 648341
931555 500560
451289 811080
275183 969584
28984 255298
971792 603789
290513 485349
63131 4066
4993 123137
6...

output:

629719
695599
351561
83909
248197
337451
198910
119007
163901
59655
227999
446205
417989
21251
943060
809056
530827
874242
191820
190031
801897
103766
56477
114351
865146
677995
221128
278416
622213
580214
223576
311442
602474
22418
10224
852728
546723
793775
936547
18769
695901
400642
163668
131209...

result:

ok 1000000 numbers

Test #20:

score: 20
Accepted
time: 4516ms
memory: 201784kb

input:

999995 999995
583944 643022
937405 396314
664613 53634
851937 959727
682251 262542
332058 495766
657697 254050
368945 648181
175500 409923
987447 663924
254362 212955
27186 48916
280933 263728
376404 531873
991175 304206
637107 818051
718055 603621
219979 376988
818262 602594
182634 716446
199549 42...

output:

632589
674038
421313
484901
850231
228438
726812
388070
754679
535180
282906
25258
23979
984419
946557
113528
158768
603008
400873
344667
550891
469199
301296
257606
310724
113289
667078
869781
273972
414507
36966
141760
266471
765423
406244
590218
968606
19385
46201
1519
39710
219752
427711
92415
6...

result:

ok 999995 numbers

Test #21:

score: 20
Accepted
time: 3843ms
memory: 200924kb

input:

1000000 1000000
447619 721571
584229 399494
614240 965088
204795 826646
448424 16919
866545 997174
657300 767860
490299 320401
773237 573187
494243 285955
630714 533001
811444 822428
571608 72868
490258 309897
415722 410945
967983 117451
928078 616204
939548 894410
622192 510197
568931 946541
594774...

output:

126935
145263
465828
476012
65533
42535
698958
492977
890460
175334
194482
579490
712753
695360
739259
853109
150308
228326
104307
750668
105724
512722
81223
925835
382011
92740
184439
918760
104781
443444
190528
204480
31387
835933
934756
66557
530040
18748
381135
735303
30969
306423
125340
33784
7...

result:

ok 1000000 numbers

Test #22:

score: 20
Accepted
time: 4567ms
memory: 201552kb

input:

1000000 1000000
563011 69168
799795 322619
625047 265910
302908 329651
912744 87238
944646 651913
883129 540212
154443 308737
809426 72823
394629 784304
722788 621382
600870 838097
351383 148859
863544 219752
279356 573627
168233 338737
748815 773018
779663 11919
819024 722313
784467 172146
429478 8...

output:

931763
507651
2891
279771
232600
358080
668537
179794
209284
323888
8579
28498
724380
790693
913562
742416
237268
811986
666427
110749
337341
45733
893515
541297
415398
387692
840824
806569
300977
7251
210484
844863
141462
768680
694505
368468
120097
826126
58764
335812
638189
244154
574681
705704
4...

result:

ok 1000000 numbers

Test #23:

score: 20
Accepted
time: 4632ms
memory: 201584kb

input:

999999 999998
549904 780695
952102 832337
321082 698470
315767 459429
88631 296205
224845 246509
898700 395777
277973 403130
437048 186188
393884 45421
993904 511710
94564 534733
606016 40744
294330 813572
957779 147335
315712 805921
835751 978801
764915 214826
33564 855982
174621 309776
202372 4386...

output:

174929
683585
23870
145186
591016
146066
527528
825193
571238
633087
677612
57791
250466
20273
94886
182538
544573
426519
148353
8778
283430
226442
23493
85639
27407
955906
174708
192446
139541
672132
487223
351873
370386
161299
345077
163475
831109
778917
16063
732
359442
2254
570035
292433
527730
...

result:

ok 999998 numbers

Test #24:

score: 20
Accepted
time: 4557ms
memory: 201540kb

input:

1000000 1000000
875926 620802
927410 582189
453297 27134
625927 194770
285863 198107
758448 934846
628394 508725
472741 244210
63544 906210
694594 426018
95086 100899
791006 237438
459186 660344
422538 932319
786905 189449
38062 851236
615341 58794
935296 669950
41835 430485
638425 532888
887360 956...

output:

314353
240231
222662
88736
363994
50619
459541
704120
315257
144316
755815
369269
315280
552329
382758
939953
104281
715086
891561
724596
298843
885639
44610
110591
551022
693346
436359
15173
17290
155448
18605
889862
815068
470390
238390
874503
68546
21916
704446
344934
357808
355718
103549
888118
...

result:

ok 1000000 numbers

Subtask #4:

score: 0
Skipped

Dependency #1:

0%

Subtask #5:

score: 0
Skipped

Dependency #1:

0%