QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#369273#7791. 通道建设 Passage Constructionyyyyxh63 2296ms203236kbC++143.6kb2024-03-27 22:54:052024-03-27 22:54:06

Judging History

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

  • [2024-03-27 22:54:06]
  • 评测
  • 测评结果:63
  • 用时:2296ms
  • 内存:203236kb
  • [2024-03-27 22:54:05]
  • 提交

answer

#include "passageconstruction.h"
#include <vector>
#include <numeric>
#include <algorithm>
#define fi first
#define se second
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
const int N=10003,M=5003;
int n,cnt;
int lc[N],rc[N],fa[N],nd[N];
vi vec[N];
void rebuild(int u,int fs){
	int las=u;
	for(int v:vec[u]){
		if(v==fs) continue;
		rebuild(v,u);
		int p=++cnt;
		nd[p]=u;
		fa[lc[p]=v]=p;
		fa[rc[las]=p]=las;
		las=p;
	}
}
bool del[N];
int sz[N],sn[N];
void dfs(int u){
	sz[u]=1;sn[u]=0;
	if(lc[u]&&!del[lc[u]]){
		dfs(lc[u]);sz[u]+=sz[lc[u]];
		if(sz[lc[u]]>sz[sn[u]]) sn[u]=lc[u];
	}
	if(rc[u]&&!del[rc[u]]){
		dfs(rc[u]);sz[u]+=sz[rc[u]];
		if(sz[rc[u]]>sz[sn[u]]) sn[u]=rc[u];
	}
}
vector<int> lis[N];
void proc(int rt,vi cur){
	if(cur.empty()) return;
	int x=rt;
	dfs(rt);
	while(sz[sn[x]]*2>sz[rt]) x=sn[x];
	del[x]=1;
	if(x<=n){
		vi qvec=vec[x];
		if(qvec.size()==1lu) qvec.emplace_back(x);
		if(!cur.empty()){
			vi RES=QueryLCA(cur,qvec,x),out;
			for(int i=0;i<(int)cur.size();++i)
				if(RES[i]) lis[x].emplace_back(cur[i]);
				else out.emplace_back(cur[i]);
			cur.swap(out);
		}
	}
	if(lc[x]){
		vi onin,out,in;
		if(!cur.empty()){
			vi RES=QueryLCA(cur,{nd[x],lc[x]},nd[x]);
			for(int i=0;i<(int)cur.size();++i)
				if(RES[i]) out.emplace_back(cur[i]);
				else onin.emplace_back(cur[i]);
			cur.swap(out);
		}
		if(del[lc[x]]){
			for(int p:onin) lis[x].emplace_back(p);
		}
		else{
			vi in;
			if(!onin.empty()){
				vi RES=QueryLCA(onin,{nd[x],lc[x]},lc[x]);
				for(int i=0;i<(int)onin.size();++i)
					if(RES[i]) in.emplace_back(onin[i]);
					else lis[x].emplace_back(onin[i]);
			}
			proc(lc[x],in);
		}
	}
	if(rc[x]&&!del[rc[x]]){
		vi chain,in,out;
		for(int i=rc[x];i&&!del[i];i=rc[i])
			chain.emplace_back(lc[i]);
		if(chain.size()==1lu) chain.emplace_back(nd[x]);
		vi RES=QueryLCA(cur,chain,nd[x]);
		for(int i=0;i<(int)cur.size();++i)
			if(RES[i]) out.emplace_back(cur[i]);
			else in.emplace_back(cur[i]);
		cur.swap(out);
		proc(rc[x],in);
	}
	if(x!=rt) proc(rt,cur);
}
int d[M][M],p[M][M],q[M];
int mat[N];
int len;
int dl[N],dr[N];
vpii adj[N];
void dfs(int u,int fa,int *dep){
	for(auto [v,w]:adj[u]){
		if(v==fa) continue;
		dep[v]=dep[u]+w;
		dfs(v,u,dep);
	}
}
vpii ConstructPassages(int _N,const vpii &_E){
	n=_N;
	if(n==1) return {{1,2}};
	for(auto [u,v]:_E){
		vec[u].emplace_back(v);
		vec[v].emplace_back(u);
	}
	vi init;
	for(int i=1;i<=n;++i) nd[i]=i,init.emplace_back(i+n);
	cnt=n;
	rebuild(1,0);
	proc(1,init);
	for(int i=n+1;i<=cnt;++i){
		int len=1;
		int u=nd[i],v=lc[i];
		for(int x:lis[i]){
			dl[x]=GetDistance(u,x);
			dr[x]=GetDistance(v,x);
			if(dl[x]==1||dr[x]==1) len=dl[x]+dr[x];
		}
		adj[v].emplace_back(u,len);
		adj[u].emplace_back(v,len);
	}
	for(int i=1;i<=n;++i)
		for(int x:lis[i]){
			d[x-n][i]=GetDistance(i,x);
			dfs(i,0,d[x-n]);
		}
	for(int i=n+1;i<=cnt;++i){
		int u=nd[i],v=lc[i];
		for(int x:lis[i]){
			d[x-n][u]=dl[x];dfs(u,v,d[x-n]);
			d[x-n][v]=dr[x];dfs(v,u,d[x-n]);
		}
	}
	for(int i=1;i<=n;++i){
		iota(p[i]+1,p[i]+n+1,1);
		sort(p[i]+1,p[i]+n+1,[&](int x,int y){return d[i][x]>d[i][y];});
		q[i]=0;mat[i]=0;
	}
	while(true){
		for(int i=1;i<=n;++i){
			if(q[i]>n) continue;
			if(q[i]&&mat[p[i][q[i]]]==i) continue;
			if(++q[i]>n) continue;
			int v=p[i][q[i]];
			if(!mat[v]||d[i][v]<d[mat[v]][v]) mat[v]=i;
		}
		bool flag=1;
		for(int i=1;i<=n;++i)
			if(!mat[i]){flag=0;break;}
		if(flag) break;
	}
	vpii res;
	for(int i=1;i<=n;++i) res.emplace_back(mat[i]+n,i);
	return res;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 3
Accepted

Test #1:

score: 3
Accepted
time: 1ms
memory: 6524kb

input:

1
1872884041
100 100 10000 10000
1
2294931821 2294931820

output:

Succeeded
0 0 0 0
1 2

result:

ok Accepted with 0+0 operations,sum of size(s)=0+0

Test #2:

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

input:

1
1977600624
100 100 10000 10000
5
621522394 621522399
2231003352 2231003338
464307841 464307837
1851407771 1851407768
2780336863 2780336849
314073909 314073902
1173467454 1173467430
4215033871 4215033843
2620057116 2620057098

output:

Succeeded
12 7 25 25
6 1
7 2
9 3
10 4
8 5

result:

ok Accepted with 12+7 operations,sum of size(s)=25+25

Test #3:

score: 3
Accepted
time: 2ms
memory: 8788kb

input:

1
1314992723
100 100 10000 10000
2
1174248192 1174248188
4206147071 4206147069
2894997654 2894997645

output:

Succeeded
3 3 5 6
3 1
4 2

result:

ok Accepted with 3+3 operations,sum of size(s)=5+6

Test #4:

score: 3
Accepted
time: 1ms
memory: 8524kb

input:

1
1466488642
100 100 10000 10000
3
1959342134 1959342129
3976386946 3976386946
1293201451 1293201449
4016912388 4016912383
46728190 46728181

output:

Succeeded
5 6 15 10
6 1
4 2
5 3

result:

ok Accepted with 5+6 operations,sum of size(s)=15+10

Test #5:

score: 3
Accepted
time: 2ms
memory: 10180kb

input:

1
1733551538
100 100 10000 10000
4
4255320958 4255320951
1233889267 1233889267
2022156010 2022156014
1746602236 1746602223
1796304111 1796304099
154520793 154520786
799267407 799267389

output:

Succeeded
9 6 14 18
8 1
7 2
6 3
5 4

result:

ok Accepted with 9+6 operations,sum of size(s)=14+18

Test #6:

score: 3
Accepted
time: 2ms
memory: 10156kb

input:

1
1103590331
100 100 10000 10000
4
3735090189 3735090176
179620503 179620501
1550955883 1550955882
3533004575 3533004552
2159969243 2159969227
2549716219 2549716202
1755562372 1755562356

output:

Succeeded
6 4 20 12
8 1
7 2
5 3
6 4

result:

ok Accepted with 6+4 operations,sum of size(s)=20+12

Test #7:

score: 3
Accepted
time: 1ms
memory: 6760kb

input:

1
1007922703
100 100 10000 10000
5
3347355425 3347355424
924935451 924935434
3554593528 3554593525
2830078883 2830078872
3185621515 3185621508
32902500 32902483
1057526055 1057526035
3737430162 3737430144
106424402 106424399

output:

Succeeded
6 7 15 14
8 1
6 2
10 3
9 4
7 5

result:

ok Accepted with 6+7 operations,sum of size(s)=15+14

Test #8:

score: 3
Accepted
time: 1ms
memory: 8684kb

input:

1
1401446296
100 100 10000 10000
5
4125806477 4125806476
1224445301 1224445291
1474144594 1474144597
2898586557 2898586536
879608888 879608877
3110900945 3110900930
2490037068 2490037051
422424582 422424570
1017432306 1017432295

output:

Succeeded
9 5 17 19
9 1
8 2
6 3
7 4
10 5

result:

ok Accepted with 9+5 operations,sum of size(s)=17+19

Test #9:

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

input:

1
1756894897
100 100 10000 10000
5
2081532117 2081532115
4275738287 4275738273
632146529 632146534
2424607270 2424607263
2157363450 2157363443
2463928559 2463928550
3381117807 3381117785
4186361975 4186361960
3382018566 3382018532

output:

Succeeded
9 7 29 19
10 1
9 2
8 3
6 4
7 5

result:

ok Accepted with 9+7 operations,sum of size(s)=29+19

Test #10:

score: 3
Accepted
time: 2ms
memory: 8512kb

input:

1
1465320926
100 100 10000 10000
5
2695813796 2695813789
3049323317 3049323309
231883125 231883119
3073242409 3073242392
1388430756 1388430755
183732731 183732729
1423324287 1423324267
3470698806 3470698795
354321542 354321525

output:

Succeeded
12 7 27 25
10 1
7 2
8 3
6 4
9 5

result:

ok Accepted with 12+7 operations,sum of size(s)=27+25

Subtask #2:

score: 6
Accepted

Test #11:

score: 6
Accepted
time: 0ms
memory: 14460kb

input:

2
755640766
20000 10000 200000 200000
100
4287951944 4287951892
218593589 218593610
2907028702 2907028595
100123056 100122959
3149201405 3149201229
3454414687 3454414608
1901257489 1901257490
1532337798 1532337686
836222214 836222227
187381584 187381446
1847826999 1847827071
2868544732 2868544653
41...

output:

Succeeded
164 130 1099 365
167 1
182 2
112 3
150 4
127 5
177 6
108 7
157 8
151 9
196 10
114 11
131 12
194 13
178 14
185 15
180 16
179 17
191 18
168 19
111 20
199 21
141 22
109 23
173 24
120 25
145 26
132 27
129 28
169 29
184 30
200 31
198 32
159 33
158 34
153 35
136 36
143 37
152 38
195 39
166 40
16...

result:

ok Accepted with 164+130 operations,sum of size(s)=1099+365

Test #12:

score: 6
Accepted
time: 0ms
memory: 14856kb

input:

2
587237803
20000 10000 200000 200000
98
217447661 217447616
2463641363 2463641406
3373538248 3373538212
3950835015 3950834997
2221322822 2221322872
146298284 146298141
531452967 531453049
3941453926 3941454046
3084946195 3084946149
1270490559 1270490368
1019372524 1019372347
2754251578 2754251434
5...

output:

Succeeded
183 131 993 393
164 1
185 2
106 3
135 4
103 5
166 6
144 7
149 8
169 9
120 10
101 11
131 12
152 13
108 14
190 15
155 16
171 17
130 18
150 19
151 20
170 21
121 22
154 23
188 24
162 25
181 26
107 27
133 28
176 29
192 30
165 31
109 32
177 33
167 34
153 35
183 36
114 37
173 38
146 39
110 40
143...

result:

ok Accepted with 183+131 operations,sum of size(s)=993+393

Test #13:

score: 6
Accepted
time: 0ms
memory: 12476kb

input:

2
184226984
20000 10000 200000 200000
99
547000384 547000355
872110096 872110116
1289538184 1289538247
3616724666 3616724569
636341527 636341600
2563522202 2563522274
2177548205 2177548137
3089489449 3089489506
3156380759 3156380856
944465184 944465231
823584265 823584499
333051247 333051023
1754238...

output:

Succeeded
161 116 1075 360
194 1
164 2
111 3
195 4
188 5
193 6
166 7
185 8
108 9
151 10
141 11
140 12
186 13
139 14
144 15
152 16
125 17
177 18
178 19
134 20
155 21
167 22
130 23
138 24
116 25
115 26
120 27
179 28
110 29
168 30
154 31
172 32
121 33
156 34
123 35
149 36
112 37
192 38
118 39
158 40
10...

result:

ok Accepted with 161+116 operations,sum of size(s)=1075+360

Test #14:

score: 6
Accepted
time: 0ms
memory: 14456kb

input:

2
1727138930
20000 10000 200000 200000
99
3247483138 3247483162
4084597375 4084597429
2636905019 2636904971
946660642 946660700
902149328 902149350
2382255766 2382255865
839303047 839303137
1923325547 1923325538
653690681 653690724
4175318562 4175318731
3824454449 3824454478
2650316775 2650316587
58...

output:

Succeeded
190 125 1111 416
157 1
135 2
123 3
164 4
141 5
154 6
126 7
170 8
194 9
127 10
151 11
103 12
121 13
128 14
142 15
145 16
119 17
172 18
111 19
125 20
158 21
156 22
159 23
167 24
131 25
195 26
114 27
188 28
122 29
198 30
147 31
140 32
184 33
134 34
166 35
180 36
110 37
113 38
143 39
138 40
15...

result:

ok Accepted with 190+125 operations,sum of size(s)=1111+416

Test #15:

score: 6
Accepted
time: 0ms
memory: 13140kb

input:

2
1220143324
20000 10000 200000 200000
100
693596313 693596332
62576744 62576808
1955936424 1955936264
3872655610 3872655531
1013531683 1013531829
2985331208 2985331369
2406362516 2406362582
1657349556 1657349602
1003910904 1003910721
1096398841 1096398795
1778724026 1778723842
713692268 713692342
2...

output:

Succeeded
176 127 1069 385
112 1
154 2
175 3
128 4
158 5
188 6
177 7
172 8
180 9
191 10
185 11
197 12
106 13
121 14
186 15
199 16
136 17
181 18
108 19
171 20
162 21
196 22
183 23
138 24
118 25
104 26
182 27
102 28
159 29
173 30
163 31
132 32
147 33
114 34
170 35
113 36
105 37
150 38
161 39
110 40
14...

result:

ok Accepted with 176+127 operations,sum of size(s)=1069+385

Test #16:

score: 6
Accepted
time: 0ms
memory: 12640kb

input:

2
442130601
20000 10000 200000 200000
100
3144169521 3144169542
3602466736 3602466791
26223369 26223537
866636824 866636802
1192888944 1192888905
2768179340 2768179316
992350648 992350588
1606144049 1606144118
2825460299 2825460268
2783910130 2783910118
403964521 403964517
445570315 445570360
126026...

output:

Succeeded
188 137 1044 405
181 1
109 2
199 3
130 4
191 5
183 6
118 7
117 8
150 9
173 10
107 11
154 12
104 13
190 14
145 15
152 16
102 17
136 18
196 19
175 20
127 21
153 22
141 23
113 24
148 25
176 26
180 27
200 28
143 29
184 30
194 31
138 32
120 33
166 34
122 35
121 36
106 37
112 38
129 39
169 40
18...

result:

ok Accepted with 188+137 operations,sum of size(s)=1044+405

Test #17:

score: 6
Accepted
time: 0ms
memory: 14500kb

input:

2
949343282
20000 10000 200000 200000
97
1170242583 1170242801
4247921283 4247921322
1529679099 1529679065
1051858814 1051858774
3893889966 3893889994
3958531511 3958531352
2502650796 2502650862
813064156 813064047
1048780624 1048780414
3993902928 3993902731
803344004 803343802
3547336751 3547336794...

output:

Succeeded
216 126 1030 466
139 1
184 2
189 3
131 4
144 5
134 6
112 7
106 8
194 9
124 10
125 11
186 12
192 13
108 14
191 15
155 16
166 17
159 18
104 19
148 20
105 21
115 22
120 23
145 24
187 25
171 26
163 27
174 28
181 29
103 30
111 31
141 32
170 33
119 34
127 35
177 36
99 37
122 38
118 39
130 40
151...

result:

ok Accepted with 216+126 operations,sum of size(s)=1030+466

Test #18:

score: 6
Accepted
time: 2ms
memory: 10824kb

input:

2
734508634
20000 10000 200000 200000
98
213911368 213911499
2488548419 2488548499
516780967 516780705
3349442602 3349442765
857297035 857297029
1348690665 1348690579
1548954171 1548954133
3605026599 3605026727
182470368 182470292
1455323224 1455323364
2179991017 2179991001
3209649930 3209649949
145...

output:

Succeeded
182 122 1005 403
100 1
122 2
101 3
195 4
120 5
143 6
113 7
148 8
125 9
127 10
102 11
162 12
190 13
163 14
194 15
177 16
175 17
184 18
171 19
169 20
153 21
144 22
165 23
167 24
152 25
188 26
193 27
150 28
136 29
118 30
141 31
108 32
164 33
139 34
131 35
179 36
154 37
99 38
114 39
115 40
128...

result:

ok Accepted with 182+122 operations,sum of size(s)=1005+403

Subtask #3:

score: 8
Accepted

Test #19:

score: 8
Accepted
time: 37ms
memory: 49444kb

input:

3
397960972
100000 4000 200000 200000
1000
3136131587 3136131078
3887641427 3887642253
280951546 280951198
124187343 124186744
3948118891 3948118785
2174920490 2174920140
3041102338 3041103477
489656932 489656480
3093689453 3093690199
3027233105 3027233261
967551350 967551424
215138938 215138436
251...

output:

Succeeded
697 1101 19254 1394
1778 1
1298 2
1447 3
1438 4
1228 5
1673 6
1356 7
1764 8
1657 9
1780 10
1739 11
1676 12
1629 13
1065 14
1144 15
1958 16
1218 17
1445 18
1042 19
1045 20
1776 21
1343 22
1631 23
1750 24
1376 25
1810 26
1705 27
1425 28
1746 29
1740 30
1709 31
1300 32
1524 33
1989 34
1577 35...

result:

ok Accepted with 697+1101 operations,sum of size(s)=19254+1394

Test #20:

score: 8
Accepted
time: 67ms
memory: 49500kb

input:

3
755523510
100000 4000 200000 200000
999
837610461 837610217
209552123 209552158
2202987134 2202987346
3933843218 3933843131
2783546817 2783547323
415275024 415276142
13876082 13876176
448702939 448703028
1294393612 1294394136
3910397405 3910397094
3416630484 3416630700
3215888394 3215888948
124509...

output:

Succeeded
660 1998 17948 1320
1715 1
1306 2
1763 3
1412 4
1479 5
1666 6
1192 7
1991 8
1048 9
1722 10
1936 11
1369 12
1760 13
1159 14
1556 15
1566 16
1944 17
1491 18
1662 19
1483 20
1174 21
1832 22
1152 23
1387 24
1755 25
1216 26
1797 27
1507 28
1005 29
1752 30
1136 31
1254 32
1765 33
1298 34
1886 35...

result:

ok Accepted with 660+1998 operations,sum of size(s)=17948+1320

Test #21:

score: 8
Accepted
time: 35ms
memory: 47904kb

input:

3
2042812129
100000 4000 200000 200000
998
3075748308 3075748844
1569673104 1569672823
3968525693 3968524672
2108387096 2108386924
3356390455 3356391094
3372812724 3372813320
3904961007 3904958854
4029621824 4029621345
4114486509 4114486281
1387138301 1387138067
124292409 124292880
3935517019 393551...

output:

Succeeded
700 1110 20053 1400
1802 1
1228 2
1838 3
1596 4
1186 5
1536 6
1676 7
1865 8
1497 9
1723 10
1610 11
1938 12
1871 13
1298 14
1362 15
1722 16
1442 17
1785 18
1202 19
1667 20
1982 21
1698 22
1301 23
1052 24
1444 25
1085 26
1989 27
1506 28
1010 29
1742 30
1845 31
1144 32
1531 33
1788 34
1640 35...

result:

ok Accepted with 700+1110 operations,sum of size(s)=20053+1400

Test #22:

score: 8
Accepted
time: 54ms
memory: 47832kb

input:

3
1597029305
100000 4000 200000 200000
998
2980500284 2980500361
2247716226 2247714887
988714926 988714253
1734063960 1734064121
2359409219 2359409008
411968449 411968499
155449826 155451318
555582797 555582911
45071917 45071590
1460631113 1460629818
3059213925 3059213709
2094519932 2094519250
38721...

output:

Succeeded
1807 1995 17410 3614
1732 1
1469 2
1694 3
1698 4
1230 5
1117 6
1283 7
1264 8
1616 9
1043 10
1904 11
1039 12
1797 13
1992 14
1593 15
1896 16
1353 17
1802 18
1647 19
1795 20
1678 21
1355 22
1229 23
1924 24
1947 25
1195 26
1284 27
1430 28
1302 29
1494 30
1045 31
1444 32
1256 33
1891 34
1440 3...

result:

ok Accepted with 1807+1995 operations,sum of size(s)=17410+3614

Test #23:

score: 8
Accepted
time: 58ms
memory: 48428kb

input:

3
1564467111
100000 4000 200000 200000
1000
1236547222 1236547523
2135786902 2135787064
2523622442 2523622714
1532839693 1532838477
818219113 818220033
676117995 676118414
570037547 570036834
514220702 514220842
3399494183 3399495268
2654728241 2654729498
1495037081 1495037412
2062047312 2062048382
...

output:

Succeeded
1807 1998 16794 3614
1382 1
1601 2
1938 3
1751 4
1456 5
1652 6
1064 7
1306 8
1731 9
1169 10
1934 11
1363 12
1787 13
1870 14
1101 15
1086 16
1098 17
1405 18
1591 19
1669 20
1528 21
1457 22
1863 23
1344 24
1687 25
1074 26
1038 27
1804 28
1769 29
1587 30
1471 31
1492 32
1007 33
1152 34
1728 3...

result:

ok Accepted with 1807+1998 operations,sum of size(s)=16794+3614

Test #24:

score: 8
Accepted
time: 48ms
memory: 49668kb

input:

3
213138336
100000 4000 200000 200000
999
1130123143 1130122958
687694550 687694095
929485247 929484829
3680984473 3680983776
3074105335 3074104892
1342732123 1342731927
1364720805 1364720672
2077428724 2077428538
28510235 28511166
937776441 937776505
3414480885 3414480666
3148182306 3148181509
3485...

output:

Succeeded
706 1998 16164 1412
1656 1
1426 2
1696 3
1829 4
1427 5
1124 6
1566 7
1349 8
1080 9
1860 10
1724 11
1299 12
1703 13
1120 14
1309 15
1331 16
1943 17
1955 18
1216 19
1864 20
1030 21
1045 22
1949 23
1504 24
1279 25
1471 26
1575 27
1358 28
1103 29
1366 30
1194 31
1072 32
1548 33
1823 34
1288 35...

result:

ok Accepted with 706+1998 operations,sum of size(s)=16164+1412

Test #25:

score: 8
Accepted
time: 57ms
memory: 49456kb

input:

3
924980045
100000 4000 200000 200000
998
1666991999 1666991279
148686690 148685590
324531768 324531788
2043725358 2043725640
1133184972 1133184631
853139746 853139683
1770837584 1770837761
1481554510 1481554714
1372084869 1372084950
1756084441 1756085236
2107756067 2107756010
3377586774 3377586312
...

output:

Succeeded
615 1996 16060 1230
1873 1
1896 2
1219 3
1939 4
1566 5
1372 6
1995 7
1398 8
1769 9
1238 10
1094 11
1326 12
1444 13
1977 14
1615 15
1965 16
1417 17
1811 18
1934 19
1176 20
1731 21
1237 22
1686 23
1230 24
1733 25
1991 26
1826 27
1956 28
1864 29
1904 30
1154 31
1895 32
1261 33
1680 34
1857 35...

result:

ok Accepted with 615+1996 operations,sum of size(s)=16060+1230

Test #26:

score: 8
Accepted
time: 60ms
memory: 48152kb

input:

3
774146483
100000 4000 200000 200000
999
3478842381 3478843345
606332045 606332562
2701123033 2701123563
3216754910 3216755036
1217043418 1217043429
1501603802 1501603474
1778234551 1778234769
1444790432 1444791022
2502984240 2502984288
856947428 856947122
1363006586 1363006323
1995567044 199556642...

output:

Succeeded
657 1998 19210 1314
1803 1
1887 2
1748 3
1992 4
1885 5
1834 6
1148 7
1546 8
1666 9
1469 10
1377 11
1604 12
1316 13
1324 14
1068 15
1037 16
1875 17
1906 18
1520 19
1877 20
1801 21
1798 22
1020 23
1319 24
1652 25
1132 26
1014 27
1698 28
1318 29
1456 30
1112 31
1964 32
1345 33
1982 34
1764 35...

result:

ok Accepted with 657+1998 operations,sum of size(s)=19210+1314

Test #27:

score: 8
Accepted
time: 51ms
memory: 47980kb

input:

3
82266506
100000 4000 200000 200000
999
3056998601 3056998876
1887811910 1887812134
1616045105 1616045172
1784967209 1784967615
650919784 650918837
4290024152 4290024396
154133667 154133653
754913686 754913998
3014551042 3014550770
3332698384 3332698431
304657473 304657856
1466514044 1466515029
313...

output:

Succeeded
669 1998 20641 1338
1444 1
1469 2
1313 3
1506 4
1787 5
1879 6
1971 7
1656 8
1754 9
1287 10
1822 11
1931 12
1918 13
1166 14
1523 15
1927 16
1076 17
1732 18
1288 19
1401 20
1365 21
1757 22
1926 23
1075 24
1229 25
1382 26
1261 27
1106 28
1959 29
1242 30
1825 31
1027 32
1857 33
1791 34
1889 35...

result:

ok Accepted with 669+1998 operations,sum of size(s)=20641+1338

Test #28:

score: 8
Accepted
time: 62ms
memory: 48276kb

input:

3
1746021239
100000 4000 200000 200000
1000
3649747382 3649747015
3895797253 3895797184
4001365723 4001365122
564220364 564220085
362710516 362710456
2800243662 2800243024
2073687310 2073687797
145701776 145700951
492159209 492159366
3076148714 3076148148
1548738755 1548739322
3580263095 3580262700
...

output:

Succeeded
693 1999 18781 1386
1176 1
1552 2
1393 3
1893 4
1181 5
1525 6
1827 7
1295 8
1284 9
1649 10
1678 11
1630 12
1632 13
1819 14
1035 15
1357 16
1409 17
1098 18
1808 19
1711 20
1037 21
1264 22
1299 23
1960 24
1019 25
1049 26
1591 27
1435 28
1584 29
1119 30
1440 31
1889 32
1645 33
1891 34
1999 35...

result:

ok Accepted with 693+1999 operations,sum of size(s)=18781+1386

Subtask #4:

score: 9
Accepted

Test #29:

score: 9
Accepted
time: 63ms
memory: 49764kb

input:

4
1084797752
100000 4000 200000 200000
1000
3456536122 3456534568
249115651 249115791
3576312078 3576312237
1880897416 1880895547
1944688480 1944688327
248846397 248847256
3567405828 3567405196
1084965392 1084965206
1435956247 1435955729
3887033767 3887032464
307260230 307260472
1476733874 147673312...

output:

Succeeded
1952 1000 16124 3950
1644 1
1843 2
1999 3
1647 4
1158 5
1025 6
1193 7
1673 8
1282 9
1306 10
1468 11
1439 12
1014 13
1307 14
1343 15
1670 16
1267 17
1761 18
1988 19
1857 20
1044 21
1408 22
1863 23
1086 24
1021 25
1780 26
1971 27
1530 28
1132 29
1435 30
1662 31
1487 32
1376 33
1815 34
1769 3...

result:

ok Accepted with 1952+1000 operations,sum of size(s)=16124+3950

Test #30:

score: 9
Accepted
time: 56ms
memory: 47684kb

input:

4
583125216
100000 4000 200000 200000
1000
1729488108 1729488695
2234303914 2234304325
546617298 546616102
842050918 842051470
1951502077 1951501331
4271815110 4271815116
761587681 761586756
2172224244 2172223957
2934428060 2934428507
1919912734 1919912263
1067575137 1067574604
3411448089 3411447166...

output:

Succeeded
426 1000 19614 852
1815 1
1783 2
1278 3
1880 4
1575 5
1579 6
1916 7
1035 8
1224 9
1702 10
1463 11
1233 12
1567 13
1663 14
1522 15
1364 16
1757 17
1559 18
1069 19
1779 20
1054 21
1087 22
1615 23
1111 24
1626 25
1018 26
1411 27
1494 28
1956 29
1273 30
1211 31
1879 32
1510 33
1724 34
1887 35
...

result:

ok Accepted with 426+1000 operations,sum of size(s)=19614+852

Test #31:

score: 9
Accepted
time: 84ms
memory: 47384kb

input:

4
1854731567
100000 4000 200000 200000
998
946750857 946749479
898868556 898868101
2271278746 2271277916
1796596168 1796596321
161487283 161486866
1033814116 1033814195
2395521961 2395522326
1468519383 1468519080
2816096970 2816096367
1556209002 1556208501
3292442187 3292440851
1135140030 1135140110...

output:

Succeeded
1958 998 15791 3961
1413 1
1956 2
1496 3
1626 4
1279 5
1906 6
1045 7
1595 8
1971 9
1071 10
1411 11
1937 12
1853 13
1828 14
1344 15
1432 16
1348 17
1892 18
1991 19
1995 20
1602 21
1649 22
1239 23
1050 24
1753 25
1144 26
1882 27
1197 28
1813 29
1332 30
1731 31
1438 32
1192 33
1030 34
1683 35...

result:

ok Accepted with 1958+998 operations,sum of size(s)=15791+3961

Test #32:

score: 9
Accepted
time: 145ms
memory: 47720kb

input:

4
2073988041
100000 4000 200000 200000
998
3168161931 3168162584
641363905 641362895
3784715137 3784714618
3548409026 3548409673
2737710699 2737710016
3324804481 3324803425
60841104 60840338
2010919705 2010919496
2362840315 2362840326
369236350 369237998
3600238093 3600237006
75182169 75182747
23418...

output:

Succeeded
1941 998 15844 3941
1960 1
1889 2
1346 3
1160 4
1988 5
1923 6
1626 7
1209 8
1117 9
1860 10
1419 11
1203 12
1739 13
1966 14
1342 15
1151 16
1598 17
1098 18
1163 19
1542 20
1743 21
1774 22
1746 23
1768 24
1833 25
1845 26
1464 27
1645 28
1133 29
1103 30
1340 31
1123 32
1943 33
1849 34
1426 35...

result:

ok Accepted with 1941+998 operations,sum of size(s)=15844+3941

Test #33:

score: 9
Accepted
time: 71ms
memory: 49664kb

input:

4
1770340944
100000 4000 200000 200000
998
619870796 619870703
3121053787 3121054050
4195183636 4195182734
3139119614 3139119172
3634777517 3634777854
3433281440 3433281395
1485638549 1485638667
1231357421 1231357552
1705009906 1705010057
3514693637 3514694012
4265358236 4265358262
964902776 9649023...

output:

Succeeded
1913 998 15166 3863
1767 1
1303 2
1135 3
1149 4
1817 5
1030 6
1951 7
1007 8
1429 9
1273 10
1739 11
1802 12
1826 13
1787 14
1559 15
1413 16
1551 17
1311 18
1926 19
1235 20
1609 21
1972 22
1343 23
1938 24
1318 25
1647 26
1199 27
1711 28
1907 29
1868 30
1041 31
1755 32
1002 33
1051 34
1436 35...

result:

ok Accepted with 1913+998 operations,sum of size(s)=15166+3863

Test #34:

score: 9
Accepted
time: 122ms
memory: 48216kb

input:

4
402901589
100000 4000 200000 200000
1000
1228378193 1228378597
1873458243 1873458214
2590411172 2590411391
3596693908 3596693672
442343415 442341879
1371534355 1371535333
1713867379 1713867258
2725534246 2725534433
3960722519 3960721503
1846001052 1846001387
2925453274 2925452776
1709191822 170919...

output:

Succeeded
2101 1000 18087 4203
1182 1
1827 2
1640 3
1178 4
1316 5
1605 6
1727 7
1846 8
1987 9
1616 10
1285 11
1562 12
1280 13
1588 14
1058 15
1289 16
1792 17
1049 18
1464 19
1193 20
1251 21
1312 22
1264 23
1757 24
1824 25
1412 26
1348 27
1654 28
1430 29
1195 30
1343 31
1416 32
1542 33
1098 34
1451 3...

result:

ok Accepted with 2101+1000 operations,sum of size(s)=18087+4203

Test #35:

score: 9
Accepted
time: 130ms
memory: 49848kb

input:

4
816997292
100000 4000 200000 200000
1000
3528745308 3528745448
2554369604 2554370028
2428697713 2428697760
2283123422 2283123636
2317970372 2317971439
3486243575 3486243354
914803066 914803223
3870938133 3870937913
833775363 833775109
133819724 133819108
4164722879 4164723079
4283955483 4283956051...

output:

Succeeded
2035 1000 17994 4071
1975 1
1335 2
1413 3
1312 4
1650 5
1070 6
1726 7
1435 8
1758 9
1542 10
1038 11
1648 12
1204 13
1641 14
1056 15
1566 16
1887 17
1692 18
1414 19
1579 20
1103 21
1863 22
1132 23
1218 24
1447 25
1003 26
1884 27
1035 28
1036 29
1255 30
1776 31
1747 32
1606 33
1827 34
1596 3...

result:

ok Accepted with 2035+1000 operations,sum of size(s)=17994+4071

Test #36:

score: 9
Accepted
time: 152ms
memory: 48016kb

input:

4
448483706
100000 4000 200000 200000
1000
3294405857 3294406138
1334269388 1334268750
3218236158 3218236229
1172020015 1172020961
4267095542 4267095785
884218942 884218794
2727697704 2727696787
4040088499 4040088016
3925649252 3925648708
3602778930 3602778977
25062275 25062940
782102904 782103485
4...

output:

Succeeded
1977 1000 17957 3954
1323 1
1818 2
1756 3
1417 4
1662 5
1876 6
1144 7
1775 8
1368 9
1434 10
1052 11
1771 12
1499 13
1201 14
1256 15
1173 16
1492 17
1502 18
1484 19
1803 20
1464 21
1440 22
1581 23
1287 24
1890 25
1283 26
1495 27
1360 28
1745 29
1591 30
1814 31
1958 32
1667 33
1313 34
1699 3...

result:

ok Accepted with 1977+1000 operations,sum of size(s)=17957+3954

Test #37:

score: 9
Accepted
time: 63ms
memory: 48036kb

input:

4
1345753551
100000 4000 200000 200000
1000
2505101245 2505099844
1064732384 1064732096
3514288208 3514289196
4285598713 4285598588
289512304 289512216
961277738 961276571
270988037 270987782
351038556 351038779
2313748299 2313748400
3024327557 3024327268
1007549868 1007549449
3171882049 3171882337
...

output:

Succeeded
2131 1000 16607 4299
1159 1
1759 2
1810 3
1697 4
1310 5
1093 6
1862 7
1775 8
1984 9
1074 10
1436 11
1036 12
1361 13
1049 14
1058 15
1936 16
1174 17
1700 18
1336 19
1950 20
1660 21
1886 22
1990 23
1635 24
1105 25
1969 26
1524 27
1042 28
1744 29
1795 30
1518 31
1794 32
1659 33
1053 34
1333 3...

result:

ok Accepted with 2131+1000 operations,sum of size(s)=16607+4299

Test #38:

score: 9
Accepted
time: 66ms
memory: 48284kb

input:

4
163480472
100000 4000 200000 200000
998
2002085756 2002085748
2640607139 2640605823
836452341 836452238
179712028 179712352
1546416317 1546416341
3648734029 3648733547
4142213872 4142214412
711606286 711606592
1732581221 1732580465
2405962256 2405961750
1644716795 1644717277
589785362 589783494
12...

output:

Succeeded
2100 998 17316 4228
1339 1
1861 2
1249 3
1164 4
1592 5
1247 6
1647 7
1931 8
1573 9
1412 10
1489 11
1505 12
1219 13
1876 14
1805 15
1577 16
1032 17
1280 18
1333 19
1226 20
1266 21
1028 22
1723 23
1450 24
1210 25
1834 26
1470 27
1161 28
1359 29
1123 30
1027 31
1588 32
1785 33
1796 34
1322 35...

result:

ok Accepted with 2100+998 operations,sum of size(s)=17316+4228

Subtask #5:

score: 11
Accepted

Test #39:

score: 11
Accepted
time: 91ms
memory: 48224kb

input:

5
1720909858
50000 4000 200000 100000
998
195378529 195378218
2138942224 2138942028
2421726252 2421725316
2614111628 2614111784
3778296551 3778295886
3346314089 3346313971
701234060 701233448
279201944 279202119
69826850 69826766
2173156660 2173157126
2982274003 2982273048
2306106121 2306107345
2808...

output:

Succeeded
1522 1289 13862 3101
1186 1
1515 2
1297 3
1531 4
1161 5
1917 6
1761 7
1992 8
1617 9
1598 10
1478 11
1252 12
1571 13
1627 14
1472 15
1712 16
1651 17
1828 18
1407 19
1854 20
1496 21
1710 22
1201 23
1437 24
1062 25
1947 26
1154 27
1025 28
1162 29
1445 30
1919 31
1483 32
1119 33
1414 34
1264 3...

result:

ok Accepted with 1522+1289 operations,sum of size(s)=13862+3101

Test #40:

score: 11
Accepted
time: 58ms
memory: 48036kb

input:

5
1942257410
50000 4000 200000 100000
999
164109252 164108690
821766476 821766590
800182177 800180581
3645999838 3646000976
4086503876 4086505410
2171679381 2171678745
2952329225 2952330453
1354218636 1354219071
1174819694 1174820521
2253012620 2253012650
1329779110 1329779087
2814346065 2814346500
...

output:

Succeeded
1943 1971 16166 3886
1451 1
1956 2
1593 3
1538 4
1296 5
1748 6
1429 7
1575 8
1286 9
1411 10
1468 11
1485 12
1877 13
1665 14
1674 15
1817 16
1737 17
1772 18
1145 19
1890 20
1131 21
1934 22
1272 23
1932 24
1223 25
1609 26
1164 27
1535 28
1647 29
1478 30
1768 31
1962 32
1151 33
1339 34
1969 3...

result:

ok Accepted with 1943+1971 operations,sum of size(s)=16166+3886

Test #41:

score: 11
Accepted
time: 54ms
memory: 48316kb

input:

5
161065852
50000 4000 200000 100000
1000
2966551129 2966552287
2856618787 2856618848
3795294524 3795295808
2757765097 2757764165
676105640 676105847
570204851 570205160
511088706 511090077
3497329264 3497329269
3725322378 3725322886
527017111 527016211
4071607765 4071607337
2817593784 2817593642
15...

output:

Succeeded
2097 1181 16530 4231
1559 1
1155 2
1223 3
1133 4
1156 5
1394 6
1615 7
1140 8
1942 9
1939 10
1702 11
1971 12
1228 13
1931 14
1748 15
1670 16
1428 17
1887 18
1882 19
1169 20
1958 21
1190 22
1080 23
1283 24
1360 25
1605 26
1543 27
1170 28
1741 29
1905 30
1999 31
1575 32
1937 33
1081 34
1566 3...

result:

ok Accepted with 2097+1181 operations,sum of size(s)=16530+4231

Test #42:

score: 11
Accepted
time: 64ms
memory: 48148kb

input:

5
777230405
50000 4000 200000 100000
999
3830467265 3830466694
1849159126 1849158949
2825053043 2825052212
2761591040 2761591070
939276197 939275664
3367167096 3367167288
3727731406 3727730932
406701926 406701618
530187802 530186715
3962995171 3962996546
1787609584 1787609620
993000803 993000542
158...

output:

Succeeded
1545 1327 14849 3144
1325 1
1627 2
1301 3
1222 4
1949 5
1103 6
1919 7
1775 8
1739 9
1380 10
1511 11
1641 12
1718 13
1447 14
1326 15
1327 16
1070 17
1039 18
1516 19
1740 20
1914 21
1139 22
1909 23
1029 24
1421 25
1962 26
1937 27
1338 28
1240 29
1915 30
1746 31
1884 32
1458 33
1700 34
1215 3...

result:

ok Accepted with 1545+1327 operations,sum of size(s)=14849+3144

Test #43:

score: 11
Accepted
time: 94ms
memory: 49772kb

input:

5
97972513
50000 4000 200000 100000
999
654921388 654921281
3336987454 3336987177
439399097 439398662
1551555981 1551555288
3555879532 3555880729
2903638861 2903639277
257794283 257794433
3826111358 3826111966
1708274143 1708274017
3746235685 3746236123
907908447 907908765
4116365217 4116364822
1582...

output:

Succeeded
1621 1325 14374 3301
1651 1
1712 2
1552 3
1517 4
1977 5
1478 6
1666 7
1221 8
1061 9
1729 10
1913 11
1000 12
1600 13
1504 14
1982 15
1102 16
1294 17
1815 18
1981 19
1939 20
1502 21
1704 22
1678 23
1484 24
1338 25
1767 26
1997 27
1016 28
1198 29
1381 30
1367 31
1186 32
1485 33
1428 34
1310 3...

result:

ok Accepted with 1621+1325 operations,sum of size(s)=14374+3301

Test #44:

score: 11
Accepted
time: 85ms
memory: 48052kb

input:

5
397162223
50000 4000 200000 100000
1000
2103775764 2103775539
3507938589 3507938863
4080657108 4080657210
2492592687 2492593001
111756474 111755329
3545417212 3545415789
3115563885 3115563458
2404092040 2404092248
1717324095 1717323827
2910355772 2910355898
40550063 40549395
1332934233 1332933830
...

output:

Succeeded
1460 1337 14489 2953
1505 1
1410 2
1813 3
1812 4
1495 5
1432 6
1934 7
1004 8
1157 9
1991 10
1644 11
1002 12
1117 13
1179 14
1805 15
1899 16
1827 17
1658 18
1079 19
1961 20
1684 21
1381 22
1826 23
1078 24
1066 25
1792 26
1210 27
1623 28
1021 29
1808 30
1980 31
1612 32
1122 33
1124 34
1756 3...

result:

ok Accepted with 1460+1337 operations,sum of size(s)=14489+2953

Test #45:

score: 11
Accepted
time: 35ms
memory: 47468kb

input:

5
1695502059
50000 4000 200000 100000
1000
700852541 700853138
286392703 286393228
862046288 862047179
1594299681 1594299408
3210366802 3210366961
1413959809 1413960445
3698437765 3698437869
1377184122 1377184197
281217513 281217619
145372596 145373148
502398350 502398463
2741843047 2741843594
34564...

output:

Succeeded
602 1088 20151 1204
1917 1
1913 2
1396 3
1429 4
1868 5
1037 6
1555 7
1550 8
1125 9
1864 10
1387 11
1725 12
1159 13
1736 14
1552 15
1730 16
1289 17
1210 18
1147 19
1231 20
1235 21
1117 22
1558 23
1594 24
1473 25
1752 26
1133 27
1416 28
1705 29
1028 30
1110 31
1186 32
1357 33
1204 34
1668 35...

result:

ok Accepted with 602+1088 operations,sum of size(s)=20151+1204

Test #46:

score: 11
Accepted
time: 68ms
memory: 48168kb

input:

5
1256148136
50000 4000 200000 100000
999
2016310630 2016310917
2107471344 2107470258
3472709132 3472709188
289824693 289824187
968116627 968117102
254957789 254959335
3918543752 3918543310
3679196968 3679195694
2994473794 2994473552
4244660702 4244660526
1565613257 1565613765
4153244320 4153244472
...

output:

Succeeded
1844 1996 17465 3688
1554 1
1911 2
1763 3
1637 4
1449 5
1068 6
1283 7
1206 8
1619 9
1884 10
1356 11
1777 12
1444 13
1632 14
1298 15
1089 16
1231 17
1985 18
1154 19
1019 20
1118 21
1873 22
1973 23
1677 24
1500 25
1143 26
1749 27
1744 28
1527 29
1439 30
1222 31
1737 32
1981 33
1188 34
1585 3...

result:

ok Accepted with 1844+1996 operations,sum of size(s)=17465+3688

Test #47:

score: 11
Accepted
time: 54ms
memory: 47728kb

input:

5
174080677
50000 4000 200000 100000
1000
3686639308 3686638800
2896535064 2896534994
942582287 942582342
1036404485 1036404700
2240524876 2240525002
885623407 885623800
2908065975 2908066813
132144926 132144327
4212166510 4212165968
2576925241 2576925211
2854923688 2854924082
4019207120 4019206802
...

output:

Succeeded
607 2000 19775 1214
1008 1
1810 2
1057 3
1305 4
1663 5
1055 6
1422 7
1362 8
1082 9
1235 10
1330 11
1097 12
1289 13
1871 14
1972 15
1376 16
1596 17
1848 18
1085 19
1304 20
1099 21
1950 22
1911 23
1342 24
1188 25
1505 26
1585 27
1721 28
1821 29
1661 30
1798 31
1670 32
1156 33
1903 34
1254 35...

result:

ok Accepted with 607+2000 operations,sum of size(s)=19775+1214

Test #48:

score: 11
Accepted
time: 146ms
memory: 48232kb

input:

5
1245824305
50000 4000 200000 100000
1000
3667004853 3667004169
2287697139 2287696730
2209822990 2209823892
4121239467 4121237803
1095196087 1095194911
1774546551 1774545134
1362722072 1362721338
1986032138 1986033160
3134483043 3134484458
3770232965 3770233774
4150800332 4150798469
444018341 44401...

output:

Succeeded
2496 1999 15644 4993
1924 1
1529 2
1189 3
1444 4
1583 5
1439 6
1755 7
1260 8
1946 9
1844 10
1505 11
1861 12
1521 13
1921 14
1928 15
1401 16
1399 17
1156 18
1076 19
1581 20
1356 21
1193 22
1889 23
1881 24
1837 25
1787 26
1978 27
1474 28
1452 29
1554 30
1207 31
1343 32
1898 33
1653 34
1562 3...

result:

ok Accepted with 2496+1999 operations,sum of size(s)=15644+4993

Test #49:

score: 11
Accepted
time: 140ms
memory: 49276kb

input:

5
1416201142
50000 4000 200000 100000
999
2694326229 2694325190
3006267026 3006266271
3590771525 3590772511
382357401 382355920
3477874958 3477875914
653232151 653234151
4226125318 4226123972
2278771395 2278772384
2110222591 2110223909
3320640593 3320639898
2013976833 2013977782
2032673776 203267476...

output:

Succeeded
2497 1997 15626 4997
1595 1
1986 2
1171 3
1681 4
1124 5
1218 6
1916 7
1628 8
1505 9
1162 10
1563 11
1029 12
1768 13
1856 14
1057 15
1486 16
1592 17
1981 18
1504 19
1668 20
1449 21
1293 22
1328 23
1883 24
1454 25
1975 26
1044 27
1466 28
1061 29
1677 30
1396 31
1058 32
1211 33
1924 34
1083 3...

result:

ok Accepted with 2497+1997 operations,sum of size(s)=15626+4997

Subtask #6:

score: 12
Accepted

Test #50:

score: 12
Accepted
time: 76ms
memory: 49332kb

input:

6
889180297
25000 4000 200000 100000
998
3680334935 3680334330
2957217208 2957215867
3096097757 3096097331
2843029536 2843030717
2270437916 2270437982
1841161075 1841160444
3671823118 3671823208
2166904224 2166903071
2760262295 2760263328
880472976 880472564
3147819342 3147820514
3366602035 33666019...

output:

Succeeded
2163 998 15662 4620
1029 1
1167 2
1876 3
1793 4
1104 5
1501 6
1784 7
1743 8
1904 9
1477 10
1788 11
1409 12
1556 13
1068 14
1441 15
1688 16
1338 17
1041 18
1685 19
1422 20
1824 21
1010 22
1930 23
1750 24
1650 25
1179 26
1465 27
1932 28
1225 29
1961 30
1376 31
1981 32
1663 33
1450 34
1483 35...

result:

ok Accepted with 2163+998 operations,sum of size(s)=15662+4620

Test #51:

score: 12
Accepted
time: 52ms
memory: 47848kb

input:

6
1393953829
25000 4000 200000 100000
999
945306191 945306676
862749063 862750710
1587703663 1587703760
2321904837 2321905131
3322741249 3322741330
128629140 128628755
4061072808 4061073316
3009230812 3009229891
3626184675 3626183179
3701144497 3701145089
1334455826 1334454368
3195102134 3195101407
...

output:

Succeeded
2164 999 15554 4701
1997 1
1422 2
1911 3
1347 4
1596 5
1681 6
1361 7
1679 8
1501 9
1549 10
1318 11
1099 12
1976 13
1045 14
1184 15
1909 16
1389 17
1439 18
1048 19
1223 20
1762 21
1398 22
1190 23
1272 24
1973 25
1085 26
1038 27
1624 28
1990 29
1600 30
1335 31
1109 32
1170 33
1101 34
1790 35...

result:

ok Accepted with 2164+999 operations,sum of size(s)=15554+4701

Test #52:

score: 12
Accepted
time: 54ms
memory: 48252kb

input:

6
2137907583
25000 4000 200000 100000
1000
99249012 99249101
3089074242 3089075163
3142929261 3142928885
3509452069 3509452074
4100326210 4100325388
2027856240 2027856707
1667832698 1667832002
239393593 239393607
3323558397 3323558267
87270863 87271227
2749644672 2749644377
3753692402 3753692989
671...

output:

Succeeded
443 1000 16487 1396
1054 1
1278 2
1337 3
1748 4
1430 5
1443 6
1428 7
1637 8
1655 9
1061 10
1140 11
1379 12
1257 13
1620 14
1652 15
1091 16
1456 17
1871 18
1856 19
1940 20
1480 21
1797 22
1161 23
1210 24
1611 25
1726 26
1277 27
1862 28
1939 29
1416 30
1273 31
1334 32
1617 33
1427 34
1002 35...

result:

ok Accepted with 443+1000 operations,sum of size(s)=16487+1396

Test #53:

score: 12
Accepted
time: 48ms
memory: 49448kb

input:

6
620581501
25000 4000 200000 100000
999
2430495051 2430494760
2342044260 2342044349
4168624383 4168624716
4153034330 4153033041
113541062 113539588
3734354027 3734355235
204355212 204355044
2304848470 2304848423
2783072361 2783073753
431065913 431066151
800004122 800004842
3667276533 3667275783
229...

output:

Succeeded
343 999 16723 1160
1689 1
1274 2
1884 3
1540 4
1404 5
1280 6
1803 7
1710 8
1251 9
1882 10
1430 11
1336 12
1001 13
1528 14
1102 15
1549 16
1910 17
1149 18
1950 19
1607 20
1584 21
1637 22
1508 23
1711 24
1138 25
1742 26
1724 27
1029 28
1071 29
1917 30
1982 31
1580 32
1944 33
1340 34
1265 35
...

result:

ok Accepted with 343+999 operations,sum of size(s)=16723+1160

Test #54:

score: 12
Accepted
time: 44ms
memory: 48348kb

input:

6
1540179210
25000 4000 200000 100000
998
908025469 908025772
4110515646 4110516139
1434161137 1434160239
4210047633 4210047681
2756906765 2756906979
773613891 773613906
3984390566 3984390788
1117864605 1117864853
379534092 379533510
3317517762 3317518164
1919343058 1919344136
1048781877 1048782644
...

output:

Succeeded
327 998 16546 1301
1040 1
1701 2
1254 3
1761 4
1497 5
1359 6
1179 7
1777 8
1071 9
1833 10
1442 11
1510 12
1799 13
1865 14
1266 15
1468 16
1528 17
1521 18
1552 19
1968 20
1295 21
1373 22
1222 23
1226 24
1707 25
1428 26
1433 27
1737 28
1699 29
1531 30
1805 31
1285 32
1289 33
1921 34
1504 35
...

result:

ok Accepted with 327+998 operations,sum of size(s)=16546+1301

Test #55:

score: 12
Accepted
time: 51ms
memory: 48192kb

input:

6
218843024
25000 4000 200000 100000
1000
4003665165 4003664581
989541263 989541162
1710766055 1710765338
3659822362 3659822800
2654208269 2654208393
1491873748 1491873450
1160537498 1160536441
3762298781 3762298020
3903551469 3903551390
4248337091 4248336400
1517118005 1517118186
399918797 39991852...

output:

Succeeded
230 1000 16430 822
1745 1
1725 2
1519 3
1257 4
1503 5
1425 6
1820 7
1612 8
1056 9
1231 10
1630 11
1317 12
1366 13
1649 14
1255 15
1485 16
1458 17
1789 18
1046 19
1422 20
1306 21
1983 22
1357 23
1969 24
1482 25
1958 26
1119 27
1106 28
1803 29
1926 30
1861 31
1639 32
1613 33
1685 34
1256 35
...

result:

ok Accepted with 230+1000 operations,sum of size(s)=16430+822

Test #56:

score: 12
Accepted
time: 51ms
memory: 48400kb

input:

6
846170590
25000 4000 200000 100000
998
1218684893 1218683879
1552665572 1552664853
3443478269 3443477570
1790763876 1790763016
1025362073 1025360149
2654707482 2654705839
1494316579 1494316380
2068116991 2068116277
331974024 331973737
1788075132 1788074334
953158534 953158009
586401169 586400597
2...

output:

Succeeded
215 998 15719 743
1400 1
1401 2
1072 3
1201 4
1043 5
1612 6
1273 7
1158 8
1661 9
1100 10
1553 11
1049 12
1344 13
1894 14
1777 15
1935 16
1137 17
1429 18
1134 19
1685 20
1312 21
1469 22
1108 23
1458 24
1159 25
1330 26
1947 27
1974 28
1828 29
1412 30
1573 31
1032 32
1709 33
1066 34
1743 35
1...

result:

ok Accepted with 215+998 operations,sum of size(s)=15719+743

Test #57:

score: 12
Accepted
time: 11ms
memory: 48204kb

input:

6
681304959
25000 4000 200000 100000
999
2726760615 2726761129
4070002268 4070002314
2698967410 2698967313
3149535258 3149536218
3426049564 3426049397
1255425746 1255425945
273472210 273471617
432940843 432940957
539629098 539628555
625817515 625817025
2355613233 2355613594
10360141 10360443
3239718...

output:

Succeeded
24 999 16983 1143
1658 1
1211 2
1702 3
1298 4
1214 5
1701 6
1106 7
1729 8
1885 9
1268 10
1075 11
1056 12
1000 13
1989 14
1647 15
1642 16
1739 17
1023 18
1019 19
1021 20
1055 21
1761 22
1065 23
1834 24
1130 25
1195 26
1806 27
1877 28
1068 29
1878 30
1889 31
1563 32
1920 33
1565 34
1041 35
1...

result:

ok Accepted with 24+999 operations,sum of size(s)=16983+1143

Test #58:

score: 12
Accepted
time: 0ms
memory: 47684kb

input:

6
1240372772
25000 4000 200000 100000
1000
1759289079 1759288926
1933352834 1933352077
347838835 347839028
2202749992 2202750871
3939036060 3939035178
3009870817 3009869983
3748040393 3748040424
864310002 864310105
1129152802 1129153119
718780908 718780600
1884330497 1884330296
2050569859 2050569350...

output:

Succeeded
26 1000 18000 482
1939 1
1604 2
1220 3
1740 4
1734 5
1182 6
1601 7
1728 8
1597 9
1707 10
1594 11
1135 12
1132 13
1124 14
1691 15
1107 16
1684 17
1090 18
1586 19
1081 20
1057 21
1044 22
1016 23
1035 24
1680 25
1022 26
1019 27
1578 28
1571 29
1988 30
1041 31
1040 32
1566 33
1977 34
1559 35
1...

result:

ok Accepted with 26+1000 operations,sum of size(s)=18000+482

Subtask #7:

score: 14
Accepted

Test #59:

score: 14
Accepted
time: 58ms
memory: 47584kb

input:

7
1561772597
25000 4000 200000 100000
1000
834919143 834919090
162625904 162627303
1067517190 1067517712
3410644901 3410644677
2728503196 2728502622
4133685425 4133685598
976760503 976760426
2101358026 2101358499
3583017242 3583017016
1743218912 1743220527
2609984627 2609985177
3915259025 3915259188...

output:

Succeeded
1679 1231 14883 3693
1252 1
1985 2
1607 3
1180 4
1701 5
1565 6
1997 7
1756 8
1856 9
1653 10
1820 11
1083 12
1962 13
1060 14
1825 15
1605 16
1506 17
1678 18
1795 19
1192 20
1334 21
1709 22
1917 23
1613 24
1868 25
1187 26
1752 27
1761 28
1406 29
1680 30
1397 31
1762 32
1289 33
1865 34
1275 3...

result:

ok Accepted with 1679+1231 operations,sum of size(s)=14883+3693

Test #60:

score: 14
Accepted
time: 40ms
memory: 48404kb

input:

7
1336630764
25000 4000 200000 100000
999
3754204676 3754204263
661669146 661669691
3383866850 3383866634
4286058306 4286058462
275363558 275362939
490879941 490879205
3048247936 3048247911
60895431 60895902
2012261918 2012261908
2305570243 2305570248
2756619485 2756618373
766927763 766927449
261527...

output:

Succeeded
326 1521 20335 652
1916 1
1006 2
1169 3
1653 4
1883 5
1838 6
1861 7
1233 8
1737 9
1344 10
1487 11
1361 12
1854 13
1957 14
1888 15
1264 16
1610 17
1756 18
1996 19
1958 20
1644 21
1896 22
1144 23
1396 24
1408 25
1316 26
1518 27
1199 28
1055 29
1736 30
1863 31
1231 32
1195 33
1668 34
1431 35
...

result:

ok Accepted with 326+1521 operations,sum of size(s)=20335+652

Test #61:

score: 14
Accepted
time: 50ms
memory: 48164kb

input:

7
1779405874
25000 4000 200000 100000
1000
4131992564 4131991606
1062232027 1062231506
3582875319 3582875068
1679869647 1679869620
3772280193 3772280538
4214125072 4214124839
2659083848 2659083347
1373877441 1373877158
1844973250 1844972076
3526061965 3526060499
2547082343 2547083157
1838200915 1838...

output:

Succeeded
1867 1863 16893 3751
1415 1
1102 2
1644 3
1597 4
1788 5
1951 6
1021 7
1661 8
1169 9
1209 10
1003 11
1570 12
1695 13
1734 14
1404 15
1870 16
1284 17
1206 18
1715 19
1347 20
1312 21
1096 22
1255 23
1787 24
1086 25
1532 26
1794 27
1297 28
1568 29
1790 30
1313 31
1822 32
1128 33
1436 34
1523 3...

result:

ok Accepted with 1867+1863 operations,sum of size(s)=16893+3751

Test #62:

score: 14
Accepted
time: 23ms
memory: 48456kb

input:

7
1570401939
25000 4000 200000 100000
998
3148646883 3148647333
3472091054 3472090123
278894780 278894651
57610944 57610331
1860420864 1860420782
2989090556 2989090327
4158835568 4158834777
196113056 196114393
2109982628 2109981735
3313427840 3313427593
1791526870 1791526564
871045252 871046635
1321...

output:

Succeeded
1695 1286 15347 3717
1708 1
1721 2
1069 3
1758 4
1733 5
1420 6
1906 7
1598 8
1672 9
1501 10
1039 11
1199 12
1094 13
1168 14
1511 15
1299 16
1766 17
1155 18
1521 19
1545 20
1120 21
1706 22
1547 23
1956 24
1953 25
1566 26
1763 27
1200 28
1046 29
1350 30
1093 31
1601 32
1671 33
1679 34
1397 3...

result:

ok Accepted with 1695+1286 operations,sum of size(s)=15347+3717

Test #63:

score: 14
Accepted
time: 51ms
memory: 47712kb

input:

7
1450625915
25000 4000 200000 100000
1000
1109002343 1109003135
22686111 22686391
708137842 708137834
1827926645 1827926257
4068418853 4068418436
3173412806 3173411005
435305565 435304885
663912650 663913396
3575081618 3575082276
2005743663 2005744468
2259422734 2259422527
1400805550 1400806829
101...

output:

Succeeded
1297 1425 16122 3494
1611 1
1040 2
1660 3
1314 4
1231 5
1497 6
1085 7
1355 8
1662 9
1571 10
1839 11
1142 12
1724 13
1303 14
1338 15
1188 16
1957 17
1373 18
1716 19
1872 20
1847 21
1590 22
1216 23
1835 24
1155 25
1708 26
1132 27
1057 28
1485 29
1281 30
1366 31
1694 32
1747 33
1947 34
1647 3...

result:

ok Accepted with 1297+1425 operations,sum of size(s)=16122+3494

Test #64:

score: 14
Accepted
time: 56ms
memory: 48404kb

input:

7
135746746
25000 4000 200000 100000
999
3854621486 3854622490
1569079030 1569077610
3987490504 3987489881
1484524078 1484524939
1470817867 1470817629
2723442111 2723441053
3895536593 3895535810
4009379127 4009379481
830706098 830707463
32509494 32508360
1070489719 1070490536
3334764196 3334762664
5...

output:

Succeeded
1353 1559 16259 3438
1602 1
1894 2
1946 3
1451 4
1670 5
1315 6
1033 7
1651 8
1101 9
1409 10
1848 11
1172 12
1105 13
1984 14
1639 15
1397 16
1074 17
1338 18
1402 19
1671 20
1169 21
1565 22
1914 23
1885 24
1254 25
1628 26
1595 27
1689 28
1958 29
1654 30
1061 31
1211 32
1314 33
1799 34
1854 3...

result:

ok Accepted with 1353+1559 operations,sum of size(s)=16259+3438

Test #65:

score: 14
Accepted
time: 40ms
memory: 47648kb

input:

7
2111844098
25000 4000 200000 100000
999
131730287 131729491
4234622692 4234621839
1894854842 1894855171
1857632532 1857633676
3106353509 3106353801
2640063239 2640064499
921644037 921643352
3957407885 3957409750
2539548444 2539548384
2096058913 2096059646
3789843675 3789842850
3719590991 371959020...

output:

Succeeded
1302 1531 16925 3384
1487 1
1801 2
1385 3
1716 4
1286 5
1161 6
1574 7
1518 8
1416 9
1974 10
1508 11
1079 12
1393 13
1993 14
1319 15
1074 16
1734 17
1862 18
1888 19
1327 20
1782 21
1215 22
1257 23
1893 24
1277 25
1420 26
1714 27
1643 28
1919 29
1918 30
1673 31
1229 32
1705 33
1838 34
1610 3...

result:

ok Accepted with 1302+1531 operations,sum of size(s)=16925+3384

Test #66:

score: 14
Accepted
time: 22ms
memory: 48240kb

input:

7
641335315
25000 4000 200000 100000
999
122084504 122085088
4017276980 4017277724
19577205 19577638
609865507 609864840
2949642502 2949642300
1449572439 1449573269
2586554784 2586554671
3749879720 3749879330
805233097 805233176
3505563718 3505564210
3463027822 3463028639
56206486 56206377
174519616...

output:

Succeeded
25 1998 19980 1220
1946 1
1719 2
1334 3
1338 4
1346 5
1348 6
1351 7
1733 8
1800 9
1399 10
1812 11
1783 12
1325 13
1387 14
1827 15
1965 16
1923 17
1050 18
1288 19
1621 20
1344 21
1382 22
1635 23
1232 24
1082 25
1349 26
1651 27
1255 28
1263 29
1269 30
1755 31
1741 32
1299 33
1314 34
1606 35
...

result:

ok Accepted with 25+1998 operations,sum of size(s)=19980+1220

Test #67:

score: 14
Accepted
time: 18ms
memory: 47612kb

input:

7
1902724585
25000 4000 200000 100000
999
2412323026 2412323115
1989891554 1989891443
2773765341 2773765514
265447302 265447090
4117457062 4117457651
1482561312 1482560953
1406096926 1406097254
705631463 705631517
1803953538 1803953889
458839460 458839350
1879258721 1879258324
1880425144 1880424987
...

output:

Succeeded
27 1998 19980 423
1528 1
1708 2
1262 3
1257 4
1503 5
1502 6
1237 7
1395 8
1631 9
1226 10
1222 11
1216 12
1602 13
1815 14
1813 15
1040 16
1743 17
1361 18
1179 19
1639 20
1178 21
1170 22
1100 23
1366 24
1071 25
1076 26
1724 27
1089 28
1543 29
1092 30
1332 31
1031 32
1755 33
1117 34
1132 35
1...

result:

ok Accepted with 27+1998 operations,sum of size(s)=19980+423

Test #68:

score: 14
Accepted
time: 143ms
memory: 47976kb

input:

7
1304909866
25000 4000 200000 100000
999
1295903888 1295903022
3932878443 3932876957
2811484715 2811485941
1438514539 1438514070
3806386020 3806385111
3192192194 3192192414
1991099750 1991098370
2746660665 2746658904
3585441978 3585443592
1667685273 1667682831
263427952 263426365
4181260055 4181258...

output:

Succeeded
2495 1997 15599 4990
1561 1
1425 2
1814 3
1631 4
1648 5
1790 6
1719 7
1821 8
1413 9
1121 10
1708 11
1840 12
1026 13
1940 14
1426 15
1400 16
1966 17
1757 18
1073 19
1746 20
1797 21
1645 22
1661 23
1973 24
1159 25
1196 26
1763 27
1557 28
1259 29
1550 30
1919 31
1034 32
1587 33
1490 34
1406 3...

result:

ok Accepted with 2495+1997 operations,sum of size(s)=15599+4990

Test #69:

score: 14
Accepted
time: 158ms
memory: 47700kb

input:

7
1317463763
25000 4000 200000 100000
998
2526685232 2526686705
1167751659 1167752904
4129542793 4129542553
845923368 845923839
2137792880 2137793312
2457480648 2457479423
3722627917 3722628322
1641737839 1641737029
1524460390 1524460841
24205870 24206552
796248162 796249277
3238897910 3238899020
37...

output:

Succeeded
2404 1976 14618 4851
1475 1
1817 2
1544 3
1169 4
1883 5
1213 6
1287 7
1011 8
1835 9
1539 10
1915 11
1774 12
1555 13
1863 14
1530 15
1635 16
1692 17
1502 18
1772 19
1234 20
1382 21
1766 22
1278 23
1413 24
1875 25
1010 26
1804 27
1212 28
1752 29
1769 30
1494 31
1282 32
1059 33
1614 34
1102 3...

result:

ok Accepted with 2404+1976 operations,sum of size(s)=14618+4851

Subtask #8:

score: 0
Time Limit Exceeded

Test #70:

score: 10
Accepted
time: 2296ms
memory: 202596kb

input:

8
1311447458
50000 100000 500000 200000
4999
173190562 173182163
1078196947 1078197142
1215565665 1215571165
1186082670 1186081354
2422459084 2422459806
2626070241 2626074599
207492448 207494582
2266700305 2266695214
1679673055 1679672568
3879988278 3879982030
254940475 254941572
3919251618 39192495...

output:

Succeeded
8720 6354 86147 19189
9558 1
7477 2
8967 3
8661 4
6455 5
6102 6
7246 7
7569 8
8624 9
8981 10
7078 11
8135 12
6686 13
7963 14
9615 15
9104 16
6536 17
9995 18
5760 19
5310 20
5600 21
6095 22
6017 23
9661 24
8164 25
9403 26
9295 27
5702 28
6858 29
5586 30
5444 31
8947 32
8613 33
5786 34
8377 ...

result:

ok Accepted with 8720+6354 operations,sum of size(s)=86147+19189

Test #71:

score: 10
Accepted
time: 1905ms
memory: 203236kb

input:

8
146283890
50000 100000 500000 200000
4998
2993119013 2993115357
4268970052 4268971874
808002542 808006552
892885669 892881200
2460117409 2460115710
3324732245 3324732140
54868859 54854998
1804229854 1804227421
450513797 450514478
1104546934 1104547705
2070884692 2070873353
379400982 379401581
3321...

output:

Succeeded
2216 7550 131252 4442
8882 1
9383 2
9228 3
5590 4
8471 5
8711 6
9785 7
6496 8
6436 9
5221 10
6156 11
7246 12
7691 13
5521 14
6139 15
6554 16
7990 17
9909 18
5752 19
8306 20
7722 21
5442 22
5534 23
7833 24
8178 25
7466 26
9446 27
5605 28
6988 29
6522 30
9221 31
7119 32
9088 33
9092 34
9147 ...

result:

ok Accepted with 2216+7550 operations,sum of size(s)=131252+4442

Test #72:

score: 10
Accepted
time: 1589ms
memory: 202328kb

input:

8
359304486
50000 100000 500000 200000
4999
1094705883 1094709685
1722131883 1722132595
2997024384 2997026636
3860480932 3860484415
628475092 628485245
2336751135 2336748598
3814389699 3814390104
2291095406 2291091625
2583462746 2583462819
2798317408 2798309538
2146225602 2146229179
2197058314 21970...

output:

Succeeded
9277 9480 106424 18577
8746 1
9163 2
5331 3
9912 4
8040 5
5560 6
5393 7
6565 8
7223 9
8774 10
5729 11
7415 12
8778 13
5170 14
7269 15
9660 16
5962 17
7221 18
5030 19
6655 20
6900 21
5461 22
7774 23
6058 24
7144 25
9729 26
8105 27
5119 28
7022 29
8699 30
8429 31
5130 32
5933 33
8044 34
8647...

result:

ok Accepted with 9277+9480 operations,sum of size(s)=106424+18577

Test #73:

score: 10
Accepted
time: 1347ms
memory: 202380kb

input:

8
274726151
50000 100000 500000 200000
4999
3419263031 3419258906
2999444481 2999444350
3939520462 3939526440
2959958627 2959955437
3179200434 3179194481
314093006 314083104
1172908290 1172911855
4164171409 4164165636
4266437323 4266441231
938450767 938450959
3402967524 3402968757
2430673118 2430680...

output:

Succeeded
8680 6437 90416 19033
5409 1
9224 2
7122 3
8761 4
8965 5
5537 6
5480 7
5039 8
7563 9
9585 10
6742 11
8051 12
9450 13
9862 14
8586 15
8399 16
5713 17
8442 18
8923 19
6951 20
7078 21
6262 22
9315 23
6248 24
8919 25
7420 26
8866 27
7376 28
8151 29
5277 30
8865 31
9430 32
8130 33
7893 34
7332 ...

result:

ok Accepted with 8680+6437 operations,sum of size(s)=90416+19033

Test #74:

score: 10
Accepted
time: 1765ms
memory: 202444kb

input:

8
36542142
50000 100000 500000 200000
4998
1882767946 1882768363
2002146634 2002148253
2634053693 2634052789
1026701278 1026688769
2616046340 2616047360
3871226190 3871226271
826813115 826802828
407974325 407972617
308792051 308793619
1589844798 1589845765
2250581592 2250578704
1119903193 1119902668...

output:

Succeeded
5882 7027 97290 16573
7880 1
5812 2
6478 3
7086 4
6785 5
9149 6
8562 7
8455 8
6965 9
8058 10
9121 11
7975 12
6905 13
9581 14
8551 15
9305 16
7396 17
9651 18
8043 19
7021 20
8998 21
6583 22
8190 23
6581 24
9898 25
7464 26
5566 27
6814 28
6829 29
8963 30
8586 31
6091 32
6597 33
9115 34
8860 ...

result:

ok Accepted with 5882+7027 operations,sum of size(s)=97290+16573

Test #75:

score: 10
Accepted
time: 1926ms
memory: 202428kb

input:

8
1487850256
50000 100000 500000 200000
4998
1811651536 1811650670
345905379 345902625
2279108766 2279111434
2091518940 2091524010
3909207465 3909209873
3388023095 3388020461
4146491221 4146487463
335162845 335161804
1825736789 1825741802
4134879931 4134887877
954293244 954286743
619524094 619526641...

output:

Succeeded
6237 7571 97364 17036
8890 1
6547 2
7311 3
7526 4
9503 5
8766 6
7625 7
8324 8
6507 9
7284 10
5010 11
5820 12
7484 13
7261 14
7224 15
7060 16
6119 17
8427 18
5380 19
5125 20
8682 21
5625 22
8584 23
9256 24
5637 25
7662 26
6084 27
5742 28
7115 29
6066 30
9996 31
9817 32
7821 33
6971 34
5386 ...

result:

ok Accepted with 6237+7571 operations,sum of size(s)=97364+17036

Test #76:

score: 10
Accepted
time: 2009ms
memory: 202600kb

input:

8
1221498280
50000 100000 500000 200000
4998
2995611046 2995612152
3821228370 3821223946
2603755886 2603749274
4253723935 4253721827
1284666231 1284667975
3724747876 3724742578
511189298 511194763
3517774027 3517770230
3839257128 3839260219
2120621563 2120626674
2987809269 2987806806
4029661482 4029...

output:

Succeeded
5503 7259 95715 16205
7469 1
5844 2
5552 3
5912 4
6336 5
7403 6
8809 7
6958 8
6284 9
7275 10
7888 11
6517 12
9217 13
7043 14
6863 15
6769 16
5902 17
7898 18
7463 19
5575 20
8767 21
6087 22
7666 23
5488 24
6504 25
9536 26
5756 27
5044 28
7921 29
8906 30
7435 31
9743 32
7225 33
8573 34
6469 ...

result:

ok Accepted with 5503+7259 operations,sum of size(s)=95715+16205

Test #77:

score: 10
Accepted
time: 581ms
memory: 202568kb

input:

8
587527602
50000 100000 500000 200000
4999
3568373793 3568376644
1120949625 1120946940
415496958 415496926
12393946 12392788
386545771 386532889
4139741816 4139743781
561101154 561098999
256455977 256456345
3867681645 3867688124
934936599 934942934
3224959264 3224945918
3353558087 3353557351
100232...

output:

Succeeded
33 9998 109978 3682
5213 1
5174 2
6085 3
5175 4
5187 5
6137 6
9261 7
5211 8
8647 9
6358 10
5226 11
9060 12
6163 13
5231 14
6178 15
6070 16
9458 17
5239 18
6213 19
9834 20
5243 21
6230 22
8811 23
5173 24
6248 25
6257 26
6261 27
5885 28
6739 29
5894 30
5905 31
5911 32
5943 33
8255 34
5319 35...

result:

ok Accepted with 33+9998 operations,sum of size(s)=109978+3682

Test #78:

score: 10
Accepted
time: 642ms
memory: 202568kb

input:

8
1394126129
50000 100000 500000 200000
5000
3535160872 3535160998
2231302465 2231289478
456729403 456731555
2086709903 2086708267
4035270421 4035268777
3771632269 3771645711
4192491848 4192489822
3316315203 3316302642
1887846361 1887831530
1613070769 1613085466
1693599113 1693601030
4198542233 4198...

output:

Succeeded
31 10000 120000 4504
8612 1
9516 2
5123 3
8913 4
5582 5
5585 6
5595 7
5603 8
5609 9
5648 10
6535 11
5666 12
9213 13
5109 14
5675 15
5676 16
5708 17
7687 18
5763 19
5962 20
5782 21
6562 22
5814 23
8165 24
8759 25
8417 26
6766 27
9816 28
6790 29
6306 30
8155 31
8494 32
5812 33
7939 34
7778 3...

result:

ok Accepted with 31+10000 operations,sum of size(s)=120000+4504

Test #79:

score: 0
Time Limit Exceeded

input:

8
798061011
50000 100000 500000 200000
4998
909931267 909922860
4047965918 4047969477
3648796296 3648794907
4128167602 4128163056
937507996 937506719
3406709348 3406716060
2859206410 2859204776
3876175763 3876164150
104431102 104422384
3251853137 3251856828
4215276376 4215282690
2479989695 247999056...

output:

Unauthorized output

result:


Subtask #9:

score: 0
Time Limit Exceeded

Test #81:

score: 27
Accepted
time: 1370ms
memory: 202376kb

input:

9
574951428
15000 10000 200000 50000
5000
1781472251 1781466624
803445324 803444785
3544280892 3544283003
3151400420 3151403948
3250864128 3250871501
4189507543 4189510374
3483519516 3483520446
1003612935 1003617460
1101934749 1101931586
1948046579 1948042301
4151407804 4151401951
424123439 42412196...

output:

Succeeded
8655 6474 89655 18954
7657 1
8507 2
6313 3
6078 4
8828 5
7259 6
5632 7
9320 8
8461 9
9210 10
8108 11
7226 12
8175 13
5339 14
9245 15
8494 16
7776 17
7562 18
8780 19
5234 20
7786 21
9534 22
5463 23
7883 24
7872 25
5547 26
6904 27
8431 28
6433 29
6420 30
6114 31
8219 32
5222 33
8946 34
5136 ...

result:

ok Accepted with 8655+6474 operations,sum of size(s)=89655+18954

Test #82:

score: 27
Accepted
time: 1912ms
memory: 202716kb

input:

9
1015784000
15000 10000 200000 50000
4999
1230515063 1230515477
1648235686 1648236525
635002652 635000809
2658028480 2658040457
1408253592 1408238543
769202478 769200158
2523685577 2523682650
1538862073 1538856433
749934974 749934304
3127382239 3127383977
4154342134 4154335434
73346199 73343176
240...

output:

Succeeded
2426 7627 130921 4871
9794 1
8875 2
8065 3
8732 4
7326 5
7270 6
8500 7
9319 8
9481 9
9886 10
5839 11
8947 12
6300 13
8071 14
8211 15
8331 16
7142 17
5411 18
5511 19
5579 20
5743 21
8269 22
6705 23
7323 24
9591 25
8307 26
5680 27
7050 28
9125 29
7322 30
7319 31
8990 32
6009 33
9736 34
5882 ...

result:

ok Accepted with 2426+7627 operations,sum of size(s)=130921+4871

Test #83:

score: 27
Accepted
time: 1526ms
memory: 202408kb

input:

9
55817321
15000 10000 200000 50000
5000
1304134662 1304137877
4197466605 4197473870
3162827674 3162830057
741742835 741739475
2858391371 2858385511
3780001353 3779989619
3359702465 3359688510
3231387076 3231389835
3542793473 3542789123
3066772403 3066766651
1875041823 1875040807
2534345455 25343430...

output:

Succeeded
9088 9545 105914 18207
9529 1
7890 2
9301 3
8940 4
5001 5
7709 6
6493 7
9617 8
8418 9
7405 10
8986 11
5864 12
6176 13
7722 14
5084 15
5121 16
7118 17
9875 18
7022 19
9841 20
8471 21
5343 22
5611 23
6701 24
7440 25
6540 26
8567 27
8461 28
9409 29
7851 30
8852 31
6060 32
8119 33
7026 34
8861...

result:

ok Accepted with 9088+9545 operations,sum of size(s)=105914+18207

Test #84:

score: 27
Accepted
time: 1980ms
memory: 202344kb

input:

9
166393219
15000 10000 200000 50000
5000
2387124620 2387130367
1192773320 1192773098
2763055432 2763061802
849111984 849112355
1635031749 1635029798
1336542382 1336548437
3125990946 3125991620
4042871186 4042867438
4013879184 4013872960
149886626 149896462
354019436 354022814
3062987676 3062987592
...

output:

Succeeded
9463 9851 102352 18976
6878 1
8392 2
7157 3
8429 4
6635 5
6293 6
7723 7
9997 8
8796 9
9939 10
9781 11
7576 12
8201 13
5588 14
6240 15
8021 16
5510 17
8500 18
6631 19
8764 20
8644 21
6659 22
8421 23
5585 24
8501 25
5965 26
6224 27
7004 28
8821 29
5610 30
9469 31
5602 32
5809 33
5237 34
7006...

result:

ok Accepted with 9463+9851 operations,sum of size(s)=102352+18976

Test #85:

score: 27
Accepted
time: 1958ms
memory: 202544kb

input:

9
2023272264
15000 10000 200000 50000
4999
2666862814 2666858610
1075110989 1075112993
1120588648 1120591355
462044663 462038416
1789207962 1789200130
1044379505 1044378584
4181242805 4181236060
3740541105 3740536540
7426000 7423251
240646227 240645680
3295646628 3295657806
1238719994 1238717232
193...

output:

Succeeded
4562 7066 104554 16384
9865 1
6861 2
7267 3
7435 4
6340 5
7582 6
5908 7
6644 8
8844 9
6221 10
7611 11
8227 12
7565 13
6365 14
8702 15
6651 16
5979 17
6448 18
9548 19
7118 20
7740 21
7799 22
5920 23
6712 24
5625 25
6119 26
7467 27
6570 28
8072 29
7268 30
5106 31
9867 32
7242 33
6796 34
8539...

result:

ok Accepted with 4562+7066 operations,sum of size(s)=104554+16384

Test #86:

score: 27
Accepted
time: 1509ms
memory: 202540kb

input:

9
1001789557
15000 10000 200000 50000
4999
2993900768 2993911387
4242927042 4242918648
1614558285 1614557906
1742595076 1742601302
2633784494 2633782949
58049529 58063585
1839417549 1839422075
3641885886 3641888995
4222704415 4222712528
2367129381 2367134322
801863126 801860103
3597714353 3597717099...

output:

Succeeded
3602 6473 106090 16453
9016 1
9731 2
7318 3
5787 4
6993 5
6014 6
9856 7
9054 8
9794 9
9104 10
7047 11
6527 12
7824 13
9695 14
8597 15
6436 16
6695 17
8900 18
6333 19
8760 20
9620 21
6081 22
8633 23
8627 24
6181 25
6266 26
8710 27
7878 28
5800 29
7028 30
8129 31
6641 32
8815 33
7528 34
8856...

result:

ok Accepted with 3602+6473 operations,sum of size(s)=106090+16453

Test #87:

score: 27
Accepted
time: 1647ms
memory: 202576kb

input:

9
157768064
15000 10000 200000 50000
5000
204641424 204643667
2330684444 2330678743
3612500362 3612500228
1025583801 1025581548
2577252381 2577258890
2861460971 2861463883
4223297569 4223295680
2356891898 2356892082
51639631 51640704
1628181782 1628184093
1087309069 1087308835
1500980657 1500981495
...

output:

Succeeded
4173 6996 102732 15896
7795 1
6387 2
8353 3
5064 4
6606 5
9524 6
7066 7
7787 8
7089 9
9597 10
7577 11
7853 12
7037 13
6436 14
9432 15
7219 16
9105 17
5134 18
7724 19
8443 20
7689 21
7218 22
9388 23
6501 24
8223 25
5782 26
5183 27
5693 28
5504 29
7836 30
9341 31
7921 32
9118 33
6915 34
7036...

result:

ok Accepted with 4173+6996 operations,sum of size(s)=102732+15896

Test #88:

score: 27
Accepted
time: 1335ms
memory: 202368kb

input:

9
1910293975
15000 10000 200000 50000
4998
289267748 289275041
917858779 917848068
3774441477 3774431277
4281286892 4281290209
450881121 450874816
1097210834 1097204019
1841904834 1841900810
3560440391 3560441328
1399494562 1399493396
1040535764 1040544860
4266745616 4266747425
877486823 877493892
3...

output:

Succeeded
8687 6423 93541 18946
9462 1
7127 2
5334 3
5819 4
8109 5
8417 6
5033 7
6147 8
6254 9
7363 10
9366 11
9111 12
9165 13
5658 14
7850 15
7846 16
6001 17
8784 18
7356 19
8949 20
6971 21
6030 22
8198 23
4999 24
9423 25
6409 26
9748 27
8159 28
8418 29
6909 30
7199 31
5981 32
9146 33
6037 34
6438 ...

result:

ok Accepted with 8687+6423 operations,sum of size(s)=93541+18946

Test #89:

score: 27
Accepted
time: 1681ms
memory: 202424kb

input:

9
1476673980
15000 10000 200000 50000
4999
387974521 387973579
4090605526 4090609432
2305798928 2305786545
2755224288 2755219131
590807156 590807358
1167115818 1167121758
4152334467 4152334979
412444727 412439395
171000664 171001218
1280685725 1280677572
3324105669 3324108253
35221841 35222123
10981...

output:

Succeeded
6441 7303 95714 17106
8990 1
7603 2
9084 3
5368 4
5885 5
9158 6
7522 7
7833 8
6068 9
9611 10
8042 11
5783 12
8166 13
8862 14
5122 15
8752 16
5199 17
9830 18
9877 19
7165 20
5439 21
8324 22
9134 23
8516 24
8684 25
8479 26
7477 27
6440 28
5387 29
5480 30
8598 31
9637 32
6202 33
8280 34
7123 ...

result:

ok Accepted with 6441+7303 operations,sum of size(s)=95714+17106

Test #90:

score: 27
Accepted
time: 1861ms
memory: 202564kb

input:

9
1290433813
15000 10000 200000 50000
4999
1479888307 1479891394
1589882388 1589877104
2251585022 2251581967
1090204205 1090203067
1606578815 1606575870
2804677664 2804675931
1108827585 1108828115
16271055 16274494
535723581 535713922
3804488080 3804481840
3120837039 3120834633
4202384962 4202386665...

output:

Succeeded
6288 7576 99873 16795
8598 1
6158 2
8150 3
5995 4
8237 5
6115 6
8652 7
7571 8
5959 9
7730 10
8811 11
9392 12
8017 13
7332 14
5533 15
8219 16
9098 17
8497 18
9847 19
7830 20
5903 21
6950 22
5774 23
6754 24
5869 25
5883 26
9940 27
6839 28
8661 29
7527 30
7777 31
5341 32
9432 33
6189 34
6126 ...

result:

ok Accepted with 6288+7576 operations,sum of size(s)=99873+16795

Test #91:

score: 27
Accepted
time: 1747ms
memory: 202332kb

input:

9
18492853
15000 10000 200000 50000
5000
3666252811 3666249178
2329759832 2329770906
3517440155 3517433545
3854207928 3854206022
1387919291 1387920350
92486749 92482246
3042030069 3042033096
527999494 528005339
4036989518 4036991482
3817762306 3817759620
2463154564 2463160508
3355628429 3355630454
3...

output:

Succeeded
5658 7310 98183 16656
5913 1
7988 2
8469 3
6385 4
6845 5
6765 6
7424 7
9889 8
7645 9
9669 10
8329 11
7130 12
9434 13
8741 14
6501 15
5690 16
6367 17
8985 18
9908 19
6782 20
6514 21
5117 22
8327 23
5720 24
9817 25
5528 26
6403 27
7678 28
5852 29
9474 30
9746 31
8148 32
5961 33
8134 34
7318 ...

result:

ok Accepted with 5658+7310 operations,sum of size(s)=98183+16656

Test #92:

score: 27
Accepted
time: 611ms
memory: 202600kb

input:

9
1308257742
15000 10000 200000 50000
4998
381070829 381068229
3231736638 3231742571
3564816540 3564818117
1534880820 1534878996
885304089 885297721
2902010232 2902003866
871072211 871078795
1322721005 1322719399
2493768993 2493768974
14560875 14556154
453293899 453292378
2079160779 2079161603
10489...

output:

Succeeded
32 9996 109956 3347
7587 1
8249 2
8259 3
7767 4
9710 5
8267 6
8268 7
8282 8
9751 9
9756 10
7017 11
7025 12
8291 13
8295 14
8463 15
8335 16
9762 17
8350 18
8353 19
8378 20
8390 21
9770 22
8392 23
8396 24
7517 25
8198 26
6668 27
6672 28
9790 29
9433 30
8154 31
8155 32
6831 33
6992 34
8181 35...

result:

ok Accepted with 32+9996 operations,sum of size(s)=109956+3347

Test #93:

score: 27
Accepted
time: 645ms
memory: 202704kb

input:

9
652929959
15000 10000 200000 50000
5000
3847044414 3847043757
1285945202 1285943482
3636482240 3636483345
3221986728 3221984915
3250269937 3250266824
4130003768 4130001192
859846378 859841806
1528689337 1528691651
949713237 949714931
736092342 736092036
1349545195 1349549994
1579408136 1579407469
...

output:

Succeeded
31 10000 120000 4517
6207 1
5180 2
6005 3
9775 4
6979 5
9738 6
6391 7
7260 8
9736 9
9720 10
5424 11
7256 12
5032 13
7105 14
6375 15
9991 16
6124 17
6459 18
6432 19
9876 20
5311 21
9221 22
6292 23
6704 24
6682 25
6316 26
6615 27
6583 28
6816 29
6524 30
9168 31
9129 32
9211 33
6554 34
9951 3...

result:

ok Accepted with 31+10000 operations,sum of size(s)=120000+4517

Test #94:

score: 0
Time Limit Exceeded

input:

9
1409095588
15000 10000 200000 50000
4999
2945476315 2945474205
1573210229 1573213827
3850914021 3850917784
1423218803 1423213630
3465224232 3465227635
536020865 536030466
3782418736 3782419950
3487214117 3487217625
884504075 884505793
2736159505 2736154116
3239596796 3239604934
3807432148 38074355...

output:

Unauthorized output

result: