QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#446363#4214. Deja VuPure_FuriesTL 265ms159764kbC++142.5kb2024-06-17 09:07:412024-06-29 06:57:13

Judging History

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

  • [2024-06-29 06:57:13]
  • 管理员手动重测本题所有提交记录
  • 测评结果:TL
  • 用时:265ms
  • 内存:159764kb
  • [2024-06-28 21:31:34]
  • hack成功,自动添加数据
  • (/hack/708)
  • [2024-06-17 09:07:41]
  • 评测
  • 测评结果:0
  • 用时:262ms
  • 内存:159732kb
  • [2024-06-17 09:07:41]
  • 提交

answer

#pragma GCC optimize("Ofast,unroll-loops")
#include<bits/stdc++.h>
using namespace std;
const int inf=1000000007; 
int w[1048576][32],I,G[2];
int msk,pm[16][2];
void pu(int k){
	memset(w[k],0,64);
	for(int i=2;i<16;i+=2)
		for(int K=0;K<2;K++){
			pm[i][K]=((i&2)||w[k<<1|K][i>>1]!=w[k][pm[(i>>2)<<1][K]])+pm[(i>>2)<<1][K]<<1;
			if(w[k][pm[i][K]]<w[k<<1|K][i])
				w[k][pm[i][K]|1]=max(w[k][pm[i][K]],w[k<<1|K][i|1]),
				w[k][pm[i][K]]=w[k<<1|K][i];
			else
				w[k][pm[i][K]|1]=max(w[k][pm[i][K]|1],w[k<<1|K][i|(w[k][pm[i][K]]==w[k<<1|K][i])]);
		}
}
int mp[32];
void PD(int k,int *F){
	for(int K=(k<<1);K<(k+1<<1);K++){
		F[K&1]=0;
		for(int i=2;i<32;i+=2){
			mp[i]=((i&2)||w[K][i>>1]!=w[k][mp[(i>>2)<<1]])+mp[(i>>2)<<1]<<1;
			w[K][i]=min(w[K][i],w[k][mp[i]]);
			if(msk&1<<mp[i])
				F[K&1]|=1<<i;
		}
	}
	for(int i=16;i<32;i+=2)
		w[k][i]=inf;
}
void op(int _l,int _r,int l,int r,int k,int x,int v){
	if(l>_r||r<_l||l>r)return;
	int F[2],A,B=0;
	if(l<=_l&&_r<=r){
		while(v){
			A=0;
			for(int i=2;i<16;i+=2)
				if(1<<i&v)
				if(w[k][i]<x){
					if(i<8)
						A|=(1<<(i<<1)),
						A|=(4<<(i<<1));
					else
						w[k][i<<1]=min(w[k][i<<1],I),
						w[k][i+1<<1]=min(w[k][i+1<<1],I);
				}else if(w[k][i+1]<x){
					w[k][i]=min(w[k][i],x);
					if(i<8)
						A|=(4<<(i<<1));
					else
						w[k][i+1<<1]=min(w[k][i+1<<1],I);
				}else B|=1<<i;
			v=A;
		}
	}else B=v;
	if(!B)return;
	msk=B;
	PD(k,F);msk=0;
	op(_l,_l+_r>>1,l,r,k<<1,x,F[0]);
	op(_l+_r+1>>1,_r,l,r,k<<1|1,x,F[1]);
	pu(k);
}
void rmk(int l,int r,int p,int k){
	if(l==r){
		for(int i=2;i<32;i<<=1)
			w[k][i]=inf;
		return;
	}
	PD(k,G);
	if(p<=(l+r>>1)) 
		rmk(l,l+r>>1,p,k<<1);
	else
		rmk(l+r+1>>1,r,p,k<<1|1);
	pu(k);
}
int n,T,m,v;
vector<pair<int,int> >opt[500003];
vector<int>qr[500003];
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	cin>>n>>T;
	for(int i=0;i<n;i++){
		cin>>v;
		opt[i].push_back({0,v});
	}
	while(T--){
		int tp,i;
		cin>>tp>>i;i--;
		if(tp==1){
			cin>>v;
			opt[i].push_back({m,v});
		}else
			qr[i].push_back(m++);
	}
	for(I=0;I<n;I++){
		for(auto j:qr[I])
			rmk(0,524287,j,1);
		opt[I].push_back({m,0});
		for(int j=0;j+1<opt[I].size();++j)
			if(opt[I][j].first!=opt[I][j+1].first)
				op(0,524287,opt[I][j].first,opt[I][j+1].first-1,1,opt[I][j].second,4); 
	}
	for(int i=1;i<524288;i++)PD(i,G);
	for(int i=0;i<m;i++)
		if(w[i+524288][16]<n)
			cout<<w[i+524288][16]+1<<'\n';
		else
			cout<<"-1\n";
}

详细

Test #1:

score: 100
Accepted
time: 56ms
memory: 158264kb

input:

11 10
1 2 3 4 5 10 9 8 7 6 8
2 1
1 3 2
2 1
1 1 2
2 1
2 5
2 6
1 9 6
1 10 7
2 5

output:

4
5
6
-1
-1
11

result:

ok 6 numbers

Test #2:

score: 0
Accepted
time: 44ms
memory: 158196kb

input:

6 7
2 3 6 10 2 3
2 3
2 1
2 5
2 4
1 4 7
1 2 3
1 4 4

output:

-1
4
-1
-1

result:

ok 4 number(s): "-1 4 -1 -1"

Test #3:

score: 0
Accepted
time: 43ms
memory: 158252kb

input:

4 9
10 7 4 4
2 2
1 3 1
1 3 4
1 4 3
1 4 8
1 4 2
2 3
1 1 7
2 2

output:

-1
-1
-1

result:

ok 3 number(s): "-1 -1 -1"

Test #4:

score: 0
Accepted
time: 39ms
memory: 158164kb

input:

10 8
3 3 7 10 4 10 5 10 4 6
1 7 1
1 2 6
1 3 3
2 1
2 3
2 2
2 10
1 6 8

output:

-1
-1
-1
-1

result:

ok 4 number(s): "-1 -1 -1 -1"

Test #5:

score: 0
Accepted
time: 59ms
memory: 158252kb

input:

3 1
2 7 6
1 1 6

output:


result:

ok 0 number(s): ""

Test #6:

score: 0
Accepted
time: 55ms
memory: 158124kb

input:

6 9
5 3 10 1 4 8
2 4
2 5
1 6 9
2 6
1 2 8
2 6
1 6 6
2 6
2 3

output:

-1
-1
-1
-1
-1
-1

result:

ok 6 numbers

Test #7:

score: 0
Accepted
time: 57ms
memory: 158208kb

input:

5 4
9 10 3 1 1
2 5
2 3
1 2 9
1 1 2

output:

-1
-1

result:

ok 2 number(s): "-1 -1"

Test #8:

score: 0
Accepted
time: 40ms
memory: 158128kb

input:

8 9
1 6 5 8 4 2 2 8
1 6 8
2 1
2 4
1 6 3
1 3 8
2 4
2 3
2 4
2 6

output:

-1
-1
-1
-1
-1
-1

result:

ok 6 numbers

Test #9:

score: 0
Accepted
time: 35ms
memory: 158188kb

input:

8 10
217400736 245088203 438403019 544276344 623130600 771196890 806732388 943246485
1 5 597885336
2 4
1 4 467449103
2 4
2 1
2 7
2 1
1 8 895177001
2 6
2 1

output:

7
7
4
-1
4
-1
4

result:

ok 7 numbers

Test #10:

score: 0
Accepted
time: 47ms
memory: 158184kb

input:

9 10
193163402 243977660 377454846 464717358 505938403 645114858 737147728 896624758 907949852
2 7
2 2
1 8 815720321
1 4 493251485
2 7
1 3 337311288
1 6 634446148
1 7 777046439
1 3 348388680
1 3 365967702

output:

-1
5
-1

result:

ok 3 number(s): "-1 5 -1"

Test #11:

score: 0
Accepted
time: 51ms
memory: 158208kb

input:

11 12
85526606 329382857 394199721 497022557 467462442 598693728 552286093 799983855 866068842 850488024 951465304
2 8
1 6 440234998
1 10 973849238
2 4
2 8
1 3 296857547
1 7 659027526
1 2 170353108
1 3 294186048
1 7 532972742
2 9
2 10

output:

-1
9
-1
-1
-1

result:

ok 5 number(s): "-1 9 -1 -1 -1"

Test #12:

score: 0
Accepted
time: 48ms
memory: 158208kb

input:

17 12
81700615 177358844 210484653 210027365 339128965 387608288 406322108 521926061 534447685 650723289 612710353 643285058 708879134 761413753 914021166 878531863 947497596
2 2
1 11 582959768
1 9 547592964
1 8 511979012
2 4
2 11
1 11 562446299
1 5 383781991
2 6
2 5
1 1 144692431
2 15

output:

6
7
14
9
8
-1

result:

ok 6 numbers

Test #13:

score: 0
Accepted
time: 35ms
memory: 158084kb

input:

16 20
107686776 187399557 261923862 271763306 275071944 329173892 426516538 443145534 527414173 683878357 635498457 740630422 848403640 813320023 889976700 976183503
2 11
2 1
1 7 415631805
2 10
1 11 762634175
2 4
2 7
1 12 709031691
2 10
2 13
2 2
2 4
2 16
2 1
1 11 716122093
2 6
1 1 70063421
2 9
1 8 5...

output:

15
4
15
7
10
15
-1
5
7
-1
4
9
13
4

result:

ok 14 numbers

Test #14:

score: 0
Accepted
time: 43ms
memory: 158176kb

input:

13 12
156189537 143195484 180384697 326238301 488125041 482236236 560273273 549954003 573091577 723307221 729723772 947621215 930274243
1 9 737120303
1 4 280169823
1 6 373132039
2 3
2 3
2 4
1 5 433523095
1 6 435547215
1 11 800378380
1 7 579236843
1 8 564152858
2 5

output:

7
7
9
9

result:

ok 4 number(s): "7 7 9 9"

Test #15:

score: 0
Accepted
time: 51ms
memory: 158192kb

input:

18 19
59610219 122962133 162846878 243630045 227212798 312668404 382475181 485322503 552195231 522627834 637369897 716064716 761450540 793669806 852048828 825968217 932181701 969223872
2 13
2 10
1 13 758223974
1 3 116194810
2 4
2 12
1 13 773203784
1 17 964126579
2 4
1 2 123312890
2 9
2 15
1 1 756492...

output:

17
13
8
15
8
13
-1
12
8
13
12

result:

ok 11 numbers

Test #16:

score: 0
Accepted
time: 47ms
memory: 158264kb

input:

195 124
14982138 14340371 21995736 15372479 29336424 34074870 40351882 36579502 54997653 57485403 62760845 63820611 72591491 72101224 82413793 86127668 94240185 87684082 97876299 104326166 105368645 121670981 112481616 121624907 124864528 139713173 138666696 148743068 157548284 148185712 166462219 1...

output:

42
101
128
22
12
167
56
116
57
75
21
173
50
102
19
64
34
137
102
144
99
93
15
81
134
70
86
25
166
145
113
7
165
25
-1
75
192
116
25
93
192
17
160
128
142
44
-1
173
27
83
98
53
95
135
93
88
153
167
11
79
87
123
95
190
69

result:

ok 65 numbers

Test #17:

score: 0
Accepted
time: 40ms
memory: 158156kb

input:

481 208
4427829 2791666 9240280 12378824 9086399 14302785 18360122 17551102 18033637 19893562 26729687 28132448 27081770 32159393 32421041 34524503 38394864 37843353 41979211 40997165 45769610 45833001 51006968 51957236 55063648 53788674 59676931 59564031 58646263 61740940 66753955 68929118 67757973...

output:

17
183
462
102
16
243
202
11
77
335
81
7
423
162
315
229
327
57
394
471
201
85
285
360
382
388
9
183
228
249
148
295
354
341
271
141
168
365
168
262
260
288
422
114
205
9
162
339
267
-1
182
119
261
-1
180
361
289
297
198
119
218
236
81
451
450
274
273
203
359
212
57
56
227
132
77
178
86
23
302
81
43...

result:

ok 93 numbers

Test #18:

score: 0
Accepted
time: 47ms
memory: 158152kb

input:

383 492
3825364 8239320 9700611 8602345 14451115 20824368 23019406 25834506 27477784 23569339 27498227 30647271 31753323 37730561 42280048 41245122 43077145 51423216 54624407 56391663 53702148 55484564 64667404 64473778 66054081 67763248 72245663 77335769 76454411 76103218 79407064 85558573 86318518...

output:

278
7
249
43
145
126
95
247
286
174
227
74
166
74
171
34
163
162
147
165
252
126
244
22
364
326
220
41
199
66
306
229
118
108
78
347
80
266
65
105
80
309
362
371
248
245
13
198
276
71
26
77
307
190
166
128
168
86
359
251
84
218
312
293
85
378
103
371
359
64
321
4
74
227
220
263
312
364
62
53
330
325...

result:

ok 248 numbers

Test #19:

score: 0
Accepted
time: 44ms
memory: 158268kb

input:

36 499
949563491 936519709 924916927 895053248 854787338 828947833 793617419 814775908 734615977 738150932 714741162 724958289 698239960 663519437 645079621 542385269 529754602 492361836 519469354 442234937 426538210 380542231 374271617 332246729 355264370 296203702 269581427 275177171 195147255 175...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
...

result:

ok 266 numbers

Test #20:

score: 0
Accepted
time: 51ms
memory: 158152kb

input:

399 235
998046309 996656147 993823957 991906931 992171052 987368672 986867819 983098593 975544961 973171106 973473472 967590126 969338289 965200807 964711940 964064315 962390073 959707924 952880810 947965073 947964928 947535641 943184735 938388913 939579771 934493926 935215622 934907551 931908207 92...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
...

result:

ok 116 numbers

Test #21:

score: 0
Accepted
time: 46ms
memory: 158212kb

input:

44 313
994520608 956056574 956365026 898208706 884750341 886864131 848188052 803692416 830508038 775479109 752797833 763616424 696894356 718139948 659504525 671719169 613198941 598382002 574971436 540054882 549948381 513261611 489523582 481704805 428512129 452322618 428175381 361212522 391709550 336...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
...

result:

ok 164 numbers

Test #22:

score: 0
Accepted
time: 39ms
memory: 158132kb

input:

13 116
972728992 896720334 814542532 705222488 706483145 557075980 462311520 431032677 468166449 337717590 345520949 240374290 171270777
1 8 562739167
1 2 875866720
1 4 678061929
1 1 932888117
1 2 985595759
1 1 955298692
2 5
2 10
1 9 441537451
2 10
2 11
1 8 394515711
2 7
2 1
1 12 138019313
2 8
2 7
2...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1

result:

ok 57 numbers

Test #23:

score: 0
Accepted
time: 45ms
memory: 158216kb

input:

359 338
994957002 996646569 990863516 991951270 986147723 988787303 979186329 980575877 975227298 972081128 972990837 964114560 966593071 960631341 956225015 956528774 953685841 951210770 950416501 947796926 945981249 938758280 937087509 933720792 934188097 929348476 930245343 924778901 924793681 91...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
...

result:

ok 174 numbers

Test #24:

score: 0
Accepted
time: 40ms
memory: 158224kb

input:

187 169
999769149 989266191 988824107 983455532 974019954 967731435 959694878 956806534 953257636 942738337 951695957 941578379 934957776 923302949 921743757 911009430 918234043 910838899 901214606 894766671 896579331 892828789 881290925 877465634 874083122 860423087 854728022 848355094 841699245 84...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1

result:

ok 76 numbers

Test #25:

score: 0
Accepted
time: 51ms
memory: 158212kb

input:

272 193
997200981 992008970 993378381 989158492 984958692 981937381 979940197 975646797 973873251 965248253 957107501 960249234 953356966 955659853 942509454 947118835 936098597 934504735 932426340 925581033 920260613 920541013 922894177 912492900 911965364 908245656 900095708 899515683 895535358 88...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
...

result:

ok 103 numbers

Test #26:

score: 0
Accepted
time: 48ms
memory: 158296kb

input:

1159 3614
999893947 999053143 997609072 998397141 996402659 996486516 995637260 994015810 990665888 991144444 992795725 989712287 989232481 986583622 985809855 985406547 984777406 986671401 982847135 981423296 984430802 981799093 979397727 977772362 980070766 978202670 976594405 978184468 977283563 ...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
97
-1
-1
-1
-1
-1
-1
-1
-1
-1
97
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
97
-1
-1
-1
461
97
-1
-1
-1
-1
-1
97
-1
-1
97
461
-1
-1
97
461
461
-1
461
-1
461
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
461...

result:

ok 1792 numbers

Test #27:

score: 0
Accepted
time: 68ms
memory: 158384kb

input:

2459 3903
999909568 999929064 999199975 998567069 997415590 997742359 997400924 997890441 997117377 996184112 996516877 994628646 995226210 993674519 994824410 994172139 993670882 992184322 993020381 991356970 991318462 991510599 991340754 989945608 990280031 990600554 989837298 989711709 988620530 ...

output:

1591
1591
1591
1591
-1
-1
-1
1591
155
155
155
1591
1591
-1
-1
1591
155
1591
-1
155
155
1591
1591
-1
-1
-1
1591
-1
1591
-1
1591
-1
-1
-1
1591
-1
-1
1591
155
-1
1591
1591
1591
-1
-1
-1
-1
-1
1591
-1
1591
1591
-1
1591
1591
1591
1591
-1
1591
-1
-1
1591
155
1591
-1
1591
1591
1591
-1
-1
1591
1591
-1
-1
15...

result:

ok 1984 numbers

Test #28:

score: 0
Accepted
time: 59ms
memory: 158260kb

input:

1848 2401
999461663 997921641 998606943 997577190 997452317 997063811 995605563 995370050 996203617 994276759 994457491 993699255 993575713 993469696 993388165 990484437 989735697 990229558 989770352 990367208 988672812 989527749 988244607 987627617 987847582 986493320 986296198 984789641 985596561 ...

output:

1087
1087
1528
1087
1087
1087
-1
1087
1378
1087
1087
-1
1528
1528
1378
1378
-1
1452
1452
1452
1087
1087
-1
1087
1087
-1
1087
1378
1378
1087
1378
1087
1087
1087
1087
1378
1087
1087
1087
1452
1087
1087
1087
1378
1087
1087
769
769
-1
-1
1378
1087
-1
769
1452
769
769
1528
1528
-1
-1
769
769
1087
1378
15...

result:

ok 1165 numbers

Test #29:

score: 0
Accepted
time: 68ms
memory: 158440kb

input:

4203 3677
688477303 783919825 412687922 891170834 476006623 740071321 551591641 537273931 750346053 79471767 10250007 579772593 873929217 702600917 894799681 150368200 601912739 196251807 293868917 154765630 469060346 49369625 430659437 129019354 565284093 469271238 552490408 543198084 23661658 6080...

output:

482
547
3830
896
1462
3912
837
2431
2380
4041
2197
1763
737
2533
300
1127
2094
3984
656
1783
354
1539
610
232
1151
47
1514
2608
773
3657
1799
1445
3702
3407
3833
1087
2197
936
1503
4009
1503
670
3104
3307
1421
814
2347
4074
813
333
3237
41
2400
3751
1671
1689
1923
1137
2511
3887
264
3350
3324
1771
5...

result:

ok 1864 numbers

Test #30:

score: 0
Accepted
time: 48ms
memory: 158244kb

input:

953 200
616015938 303866647 556279378 535884282 360748191 109602991 222487076 515908243 399883764 770073466 241250580 244095552 746150682 304666635 583573652 320190567 270514558 43841820 512817073 497465466 286430274 286192071 670289782 617935789 38313178 565746472 219277924 991414394 202073070 7978...

output:

255
596
15
885
900
768
61
95
257
738
492
34
261
170
339
779
574
71
261
757
266
562
229
854
629
600
757
316
34
165
-1
229
370
316
370
152
524
930
735
225
112
103
419
122
500
705
587
359
543
202
375
452
71
682
817
528
801
28
183
347
650
545
112
34
115
923
735
214
266
274
435
137
182
834
613
486
941
86...

result:

ok 96 numbers

Test #31:

score: 0
Accepted
time: 121ms
memory: 158892kb

input:

16135 8128
281824907 496304344 39682632 149281884 266361235 616205944 663542279 945880009 322288462 916355934 489826877 427934673 955724949 655769803 570996087 995591508 897142827 835572040 473220393 814471777 78282370 203733985 32912498 370931168 289077699 531050019 194705570 385724758 721784980 32...

output:

5971
10084
10206
4721
6166
10772
13451
4104
6660
10543
4659
14143
12091
6265
8256
12549
12467
8844
16005
12586
11255
3032
10719
12607
11895
9653
12990
12025
5630
4038
11878
11945
13453
2469
14456
1373
14276
14656
289
14070
10962
955
340
13734
15714
9198
2024
14627
9442
14206
2319
14303
4804
4310
119...

result:

ok 4058 numbers

Test #32:

score: 0
Accepted
time: 265ms
memory: 159764kb

input:

26387 27762
999988451 999910185 999913353 999837724 999775762 999791696 999739889 999644074 999770080 999582981 999641561 999495997 999444272 999579429 999385115 999497655 999321746 999393922 999316550 999248847 999213109 999248298 999055090 999137721 999000925 999102106 998957346 999015311 99900805...

output:

7447
12689
15849
20464
12689
24843
4251
20464
-1
24843
24843
1607
15849
4251
15849
20464
12689
24843
8641
12689
4251
12689
12689
12689
12689
12689
12689
24843
6101
24843
1607
12689
12689
24843
24843
20464
6101
20464
24843
24843
1607
25431
16465
1607
4251
12689
24843
4251
6101
8045
25431
-1
20464
204...

result:

ok 14072 numbers

Test #33:

score: 0
Accepted
time: 255ms
memory: 159752kb

input:

26211 27792
999999316 999901645 999905449 999955767 999876466 999718932 999780764 999675563 999692074 999577987 999520413 999503924 999576189 999575026 999415817 999411655 999282811 999321536 999342557 999289888 999163200 999165756 999160451 999178205 998970761 999077290 999000545 999033264 99893380...

output:

25268
25952
20151
1249
18339
1429
10186
23477
6141
22543
10186
1429
3434
7418
25268
11264
7418
1249
26172
7418
20997
12466
21737
17148
20151
17477
25268
6141
10186
11264
11264
-1
11264
7418
2527
22543
10186
17148
6141
1429
25952
17148
7418
10186
20997
17148
17148
17148
2527
10186
1249
23477
17477
17...

result:

ok 13896 numbers

Test #34:

score: -100
Time Limit Exceeded

input:

500000 500000
999999883 999993680 999998293 999996195 999992637 999987483 999983088 999989853 999987940 999981903 999977240 999980164 999975079 999974695 999974212 999972803 999967221 999965344 999966462 999956155 999958220 999957770 999957804 999950728 999953167 999947241 999942888 999943254 999940...

output:

57076
195978
439632
160238
102868
307407
456286
365804
47784
319401
380405
361959
177745
436977
304883
295993
366105
321827
271143
170506
154039
446779
347463
20549
209742
421992
265329
68678
107636
468330
361959
138210
95290
396915
4097
162370
449504
136235
464446
449504
197764
255767
318375
183574...

result: