QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#369398#7791. 通道建设 Passage Constructionyyyyxh63 2005ms203128kbC++143.6kb2024-03-28 07:24:132024-03-28 07:24:14

Judging History

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

  • [2024-03-28 07:24:14]
  • 评测
  • 测评结果:63
  • 用时:2005ms
  • 内存:203128kb
  • [2024-03-28 07:24:13]
  • 提交

answer

#include "passageconstruction.h"
#include <queue>
#include <vector>
#include <cassert>
#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]);
		}
	}
	queue<int> que;
	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]=1;mat[i]=0;que.emplace(i);
	}
	int cnt=0;
	while(!que.empty()){
		int u=que.front();que.pop();
		int v=p[u][q[u]];
		if(!mat[v]||d[u][v]<d[mat[v]][v]||(d[u][v]==d[mat[v]][v]&&u<mat[v])){
			if(++q[mat[v]]<=n) que.emplace(mat[v]);
			mat[v]=u;
		}
		else if(++q[u]<=n) que.emplace(u);
	}
	vpii res;
	for(int i=1;i<=n;++i) res.emplace_back(mat[i]+n,i);
	return res;
}

详细

Subtask #1:

score: 3
Accepted

Test #1:

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

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: 2ms
memory: 10740kb

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: 10300kb

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: 2ms
memory: 10572kb

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: 0ms
memory: 10176kb

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: 12104kb

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: 0ms
memory: 8672kb

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: 0ms
memory: 8472kb

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: 1ms
memory: 6972kb

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
9 1
8 2
10 3
6 4
7 5

result:

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

Test #10:

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

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
6 1
10 2
8 3
9 4
7 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: 2ms
memory: 10908kb

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
180 2
188 3
124 4
113 5
112 6
168 7
171 8
121 9
196 10
134 11
131 12
102 13
117 14
120 15
115 16
101 17
177 18
136 19
111 20
186 21
155 22
109 23
173 24
146 25
195 26
132 27
129 28
144 29
127 30
148 31
175 32
108 33
182 34
104 35
199 36
162 37
200 38
158 39
119 40
11...

result:

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

Test #12:

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

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
184 1
138 2
155 3
140 4
165 5
107 6
160 7
149 8
169 9
164 10
148 11
125 12
104 13
152 14
145 15
187 16
111 17
151 18
180 19
135 20
132 21
134 22
146 23
161 24
162 25
177 26
153 27
196 28
154 29
163 30
137 31
188 32
147 33
121 34
192 35
110 36
127 37
133 38
120 39
173 40
178...

result:

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

Test #13:

score: 6
Accepted
time: 3ms
memory: 14484kb

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
197 1
135 2
185 3
168 4
147 5
153 6
176 7
100 8
109 9
127 10
188 11
195 12
186 13
139 14
159 15
196 16
101 17
136 18
178 19
134 20
193 21
179 22
130 23
138 24
125 25
115 26
121 27
140 28
110 29
129 30
154 31
165 32
126 33
119 34
152 35
169 36
171 37
156 38
149 39
158 40
19...

result:

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

Test #14:

score: 6
Accepted
time: 3ms
memory: 12652kb

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
191 1
116 2
168 3
181 4
189 5
155 6
126 7
121 8
182 9
102 10
103 11
194 12
136 13
115 14
147 15
163 16
178 17
143 18
141 19
125 20
137 21
111 22
117 23
144 24
161 25
166 26
197 27
149 28
162 29
154 30
167 31
123 32
157 33
118 34
142 35
159 36
110 37
180 38
192 39
130 40
16...

result:

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

Test #15:

score: 6
Accepted
time: 3ms
memory: 14288kb

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
181 1
131 2
147 3
128 4
198 5
170 6
177 7
191 8
178 9
137 10
185 11
120 12
173 13
121 14
184 15
146 16
124 17
168 18
108 19
109 20
157 21
119 22
166 23
107 24
112 25
104 26
186 27
127 28
190 29
144 30
132 31
163 32
116 33
165 34
154 35
138 36
176 37
150 38
167 39
139 40
14...

result:

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

Test #16:

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

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
151 1
168 2
146 3
169 4
111 5
183 6
170 7
181 8
150 9
173 10
107 11
154 12
131 13
188 14
145 15
123 16
195 17
197 18
109 19
196 20
127 21
153 22
141 23
156 24
137 25
134 26
180 27
117 28
144 29
148 30
133 31
199 32
135 33
122 34
125 35
115 36
106 37
112 38
194 39
119 40
13...

result:

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

Test #17:

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

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
172 1
179 2
138 3
173 4
144 5
180 6
184 7
175 8
143 9
150 10
187 11
145 12
139 13
98 14
157 15
155 16
166 17
174 18
161 19
123 20
194 21
160 22
191 23
120 24
147 25
108 26
163 27
168 28
107 29
140 30
165 31
104 32
170 33
188 34
127 35
154 36
164 37
99 38
136 39
158 40
169 ...

result:

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

Test #18:

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

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
182 1
189 2
186 3
147 4
146 5
153 6
113 7
130 8
167 9
183 10
185 11
148 12
192 13
120 14
194 15
131 16
174 17
184 18
150 19
99 20
143 21
112 22
139 23
134 24
119 25
162 26
193 27
104 28
144 29
118 30
141 31
159 32
164 33
177 34
191 35
179 36
154 37
133 38
195 39
172 40
170...

result:

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

Subtask #3:

score: 8
Accepted

Test #19:

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

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: 63ms
memory: 38192kb

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: 49ms
memory: 39276kb

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: 60ms
memory: 40712kb

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: 56ms
memory: 39312kb

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: 49ms
memory: 39300kb

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: 39768kb

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: 53ms
memory: 39860kb

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: 52ms
memory: 42208kb

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: 60ms
memory: 42044kb

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: 43ms
memory: 44100kb

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
1728 1
1464 2
1969 3
1508 4
1490 5
1493 6
1986 7
1816 8
1533 9
1976 10
1718 11
1292 12
1041 13
1407 14
1753 15
1889 16
1267 17
1429 18
1339 19
1803 20
1455 21
1161 22
1680 23
1725 24
1021 25
1591 26
1185 27
1530 28
1249 29
1268 30
1662 31
1053 32
1531 33
1499 34
1135 3...

result:

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

Test #30:

score: 9
Accepted
time: 46ms
memory: 44280kb

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
1438 1
1447 2
1807 3
1813 4
1635 5
1127 6
1916 7
1387 8
1179 9
1702 10
1196 11
1365 12
1538 13
1491 14
1522 15
1364 16
1055 17
1583 18
1846 19
1394 20
1360 21
1676 22
1615 23
1962 24
1176 25
1840 26
1806 27
1930 28
1663 29
1273 30
1843 31
1269 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: 49ms
memory: 42856kb

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
1677 1
1961 2
1324 3
1471 4
1496 5
1174 6
1986 7
1145 8
1693 9
1981 10
1962 11
1882 12
1261 13
1380 14
1957 15
1161 16
1933 17
1673 18
1912 19
1012 20
1904 21
1078 22
1909 23
1050 24
1135 25
1814 26
1783 27
1952 28
1176 29
1477 30
1956 31
1305 32
1892 33
1725 34
1773 35...

result:

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

Test #32:

score: 9
Accepted
time: 48ms
memory: 41140kb

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
1659 1
1484 2
1248 3
1768 4
1642 5
1046 6
1083 7
1437 8
1885 9
1351 10
1419 11
1106 12
1411 13
1334 14
1667 15
1348 16
1077 17
1252 18
1967 19
1118 20
1278 21
1774 22
1307 23
1453 24
1459 25
1743 26
1641 27
1645 28
1021 29
1833 30
1332 31
1315 32
1112 33
1849 34
1929 35...

result:

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

Test #33:

score: 9
Accepted
time: 42ms
memory: 43640kb

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
1551 1
1745 2
1135 3
1144 4
1785 5
1203 6
1290 7
1479 8
1497 9
1248 10
1511 11
1744 12
1519 13
1619 14
1652 15
1413 16
1793 17
1653 18
1454 19
1051 20
1317 21
1842 22
1277 23
1510 24
1187 25
1848 26
1515 27
1069 28
1613 29
1091 30
1436 31
1500 32
1678 33
1217 34
1594 35...

result:

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

Test #34:

score: 9
Accepted
time: 42ms
memory: 43056kb

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
1401 1
1045 2
1991 3
1068 4
1024 5
1715 6
1261 7
1337 8
1010 9
1330 10
1534 11
1412 12
1249 13
1845 14
1098 15
1787 16
1566 17
1761 18
1884 19
1579 20
1230 21
1190 22
1957 23
1079 24
1515 25
1661 26
1795 27
1396 28
1855 29
1752 30
1972 31
1309 32
1075 33
1758 34
1252 3...

result:

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

Test #35:

score: 9
Accepted
time: 42ms
memory: 41184kb

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
1169 1
1588 2
1005 3
1607 4
1640 5
1055 6
1555 7
1572 8
1802 9
1713 10
1654 11
1829 12
1968 13
1739 14
1929 15
1837 16
1755 17
1394 18
1666 19
1365 20
1609 21
1293 22
1146 23
1777 24
1410 25
1618 26
1969 27
1880 28
1672 29
1057 30
1214 31
1230 32
1999 33
1468 34
1548 3...

result:

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

Test #36:

score: 9
Accepted
time: 34ms
memory: 41744kb

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
1288 1
1142 2
1886 3
1304 4
1266 5
1876 6
1305 7
1557 8
1581 9
1222 10
1052 11
1284 12
1389 13
1251 14
1382 15
1123 16
1764 17
1808 18
1979 19
1323 20
1161 21
1020 22
1338 23
1727 24
1942 25
1283 26
1980 27
1446 28
1449 29
1587 30
1805 31
1380 32
1436 33
1939 34
1772 3...

result:

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

Test #37:

score: 9
Accepted
time: 68ms
memory: 41508kb

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
1853 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: 63ms
memory: 42120kb

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
1379 1
1727 2
1064 3
1246 4
1072 5
1453 6
1599 7
1876 8
1992 9
1417 10
1145 11
1393 12
1484 13
1508 14
1811 15
1609 16
1502 17
1462 18
1947 19
1485 20
1451 21
1757 22
1613 23
1699 24
1728 25
1463 26
1403 27
1142 28
1414 29
1673 30
1356 31
1046 32
1296 33
1203 34
1094 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: 39ms
memory: 40476kb

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
1061 1
1005 2
1849 3
1370 4
1807 5
1734 6
1024 7
1648 8
1181 9
1598 10
1431 11
1252 12
1733 13
1627 14
1466 15
1969 16
1351 17
1828 18
1446 19
1687 20
1962 21
1864 22
1770 23
1489 24
1551 25
1821 26
1992 27
1502 28
1908 29
1630 30
1211 31
1427 32
1046 33
1976 34
1811 3...

result:

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

Test #40:

score: 11
Accepted
time: 55ms
memory: 41328kb

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
1794 1
1657 2
1186 3
1538 4
1523 5
1614 6
1364 7
1362 8
1286 9
1856 10
1105 11
1688 12
1100 13
1588 14
1157 15
1730 16
1916 17
1310 18
1145 19
1015 20
1131 21
1783 22
1540 23
1401 24
1005 25
1500 26
1164 27
1535 28
1647 29
1423 30
1026 31
1697 32
1990 33
1339 34
1644 3...

result:

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

Test #41:

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

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
1450 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: 45ms
memory: 40452kb

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
1946 1
1035 2
1775 3
1278 4
1935 5
1103 6
1836 7
1762 8
1484 9
1666 10
1022 11
1983 12
1237 13
1447 14
1326 15
1699 16
1847 17
1739 18
1697 19
1469 20
1154 21
1835 22
1849 23
1367 24
1671 25
1177 26
1887 27
1157 28
1385 29
1009 30
1206 31
1319 32
1601 33
1401 34
1732 3...

result:

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

Test #43:

score: 11
Accepted
time: 49ms
memory: 39372kb

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
1942 1
1911 2
1552 3
1727 4
1876 5
1559 6
1467 7
1785 8
1502 9
1678 10
1750 11
1554 12
1536 13
1987 14
1000 15
1719 16
1767 17
1708 18
1606 19
1846 20
1525 21
1111 22
1038 23
1377 24
1362 25
1579 26
1367 27
1016 28
1930 29
1751 30
1124 31
1186 32
1895 33
1462 34
1235 3...

result:

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

Test #44:

score: 11
Accepted
time: 36ms
memory: 40296kb

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
1332 2
1813 3
1138 4
1225 5
1227 6
1511 7
1004 8
1500 9
1075 10
1099 11
1071 12
1129 13
1822 14
1805 15
1963 16
1025 17
1082 18
1611 19
1961 20
1131 21
1888 22
1831 23
1088 24
1096 25
1307 26
1668 27
1623 28
1386 29
1580 30
1302 31
1179 32
1122 33
1764 34
1838 3...

result:

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

Test #45:

score: 11
Accepted
time: 42ms
memory: 38816kb

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: 60ms
memory: 38024kb

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: 44ms
memory: 38088kb

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: 26ms
memory: 38484kb

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
1272 1
1326 2
1415 3
1030 4
1927 5
1602 6
1542 7
1586 8
1594 9
1972 10
1168 11
1140 12
1476 13
1293 14
1753 15
1044 16
1322 17
1487 18
1294 19
1431 20
1751 21
1583 22
1273 23
1225 24
1837 25
1780 26
1185 27
1664 28
1645 29
1521 30
1154 31
1628 32
1634 33
1102 34
1638 3...

result:

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

Test #49:

score: 11
Accepted
time: 39ms
memory: 38076kb

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
1360 1
1220 2
1171 3
1707 4
1963 5
1272 6
1816 7
1540 8
1920 9
1093 10
1441 11
1061 12
1474 13
1213 14
1057 15
1320 16
1285 17
1932 18
1379 19
1802 20
1798 21
1117 22
1036 23
1789 24
1752 25
1781 26
1994 27
1342 28
1552 29
1137 30
1396 31
1118 32
1354 33
1260 34
1247 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: 36ms
memory: 37980kb

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
1212 1
1552 2
1513 3
1434 4
1831 5
1501 6
1505 7
1036 8
1131 9
1249 10
1751 11
1155 12
1661 13
1028 14
1446 15
1256 16
1824 17
1731 18
1776 19
1819 20
1752 21
1716 22
1410 23
1708 24
1073 25
1911 26
1786 27
1860 28
1471 29
1472 30
1221 31
1667 32
1994 33
1317 34
1356 35...

result:

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

Test #51:

score: 12
Accepted
time: 40ms
memory: 39264kb

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
1506 1
1800 2
1189 3
1876 4
1302 5
1305 6
1975 7
1643 8
1644 9
1799 10
1268 11
1252 12
1703 13
1668 14
1237 15
1083 16
1140 17
1007 18
1277 19
1825 20
1050 21
1322 22
1190 23
1777 24
1045 25
1558 26
1038 27
1647 28
1077 29
1101 30
1755 31
1260 32
1125 33
1161 34
1332 35...

result:

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

Test #52:

score: 12
Accepted
time: 50ms
memory: 41616kb

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
1515 1
1159 2
1988 3
1428 4
1188 5
1183 6
1532 7
1246 8
1686 9
1807 10
1506 11
1018 12
1524 13
1655 14
1043 15
1328 16
1456 17
1027 18
1672 19
1764 20
1347 21
1760 22
1110 23
1155 24
1069 25
1726 26
1640 27
1150 28
1283 29
1352 30
1400 31
1509 32
1677 33
1850 34
1903 35...

result:

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

Test #53:

score: 12
Accepted
time: 43ms
memory: 40496kb

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
1663 1
1388 2
1417 3
1716 4
1404 5
1749 6
1451 7
1362 8
1225 9
1882 10
1430 11
1487 12
1868 13
1708 14
1092 15
1325 16
1733 17
1937 18
1541 19
1904 20
1950 21
1199 22
1505 23
1649 24
1096 25
1742 26
1724 27
1620 28
1419 29
1324 30
1771 31
1673 32
1929 33
1340 34
1823 35
...

result:

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

Test #54:

score: 12
Accepted
time: 42ms
memory: 40588kb

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
1267 1
1506 2
1795 3
1761 4
1497 5
1551 6
1179 7
1013 8
1071 9
1255 10
1822 11
1966 12
1933 13
1648 14
1366 15
1836 16
1528 17
1570 18
1552 19
1635 20
1465 21
1373 22
1073 23
1226 24
1601 25
1066 26
1433 27
1986 28
1699 29
1913 30
1148 31
1386 32
1289 33
1842 34
1504 35
...

result:

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

Test #55:

score: 12
Accepted
time: 39ms
memory: 41164kb

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
1326 1
1999 2
1059 3
1329 4
1394 5
1346 6
1831 7
1960 8
1018 9
1233 10
1636 11
1878 12
1384 13
1649 14
1255 15
1343 16
1458 17
1818 18
1040 19
1826 20
1637 21
1347 22
1935 23
1847 24
1950 25
1800 26
1882 27
1106 28
1491 29
1930 30
1256 31
1991 32
1613 33
1353 34
1767 35
...

result:

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

Test #56:

score: 12
Accepted
time: 45ms
memory: 40304kb

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
1048 1
1401 2
1944 3
1417 4
1971 5
1090 6
1561 7
1375 8
1454 9
1886 10
1022 11
1196 12
1344 13
1356 14
1709 15
1119 16
1274 17
1583 18
1322 19
1895 20
1312 21
1605 22
1634 23
1060 24
1123 25
1330 26
1946 27
1061 28
1930 29
1648 30
1573 31
1114 32
1777 33
1621 34
1278 35
1...

result:

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

Test #57:

score: 12
Accepted
time: 20ms
memory: 39288kb

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: 16ms
memory: 40456kb

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: 37ms
memory: 40508kb

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
1984 1
1615 2
1182 3
1964 4
1917 5
1565 6
1454 7
1487 8
1901 9
1208 10
1457 11
1660 12
1284 13
1609 14
1180 15
1140 16
1802 17
1243 18
1669 19
1421 20
1873 21
1203 22
1439 23
1791 24
1868 25
1696 26
1752 27
1330 28
1796 29
1587 30
1246 31
1389 32
1790 33
1857 34
1538 3...

result:

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

Test #60:

score: 14
Accepted
time: 43ms
memory: 39300kb

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: 48ms
memory: 39264kb

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
1924 1
1102 2
1644 3
1819 4
1500 5
1951 6
1021 7
1896 8
1958 9
1775 10
1679 11
1812 12
1284 13
1734 14
1404 15
1535 16
1098 17
1654 18
1715 19
1875 20
1773 21
1526 22
1764 23
1582 24
1461 25
1532 26
1509 27
1297 28
1807 29
1790 30
1882 31
1212 32
1858 33
1436 34
1056 3...

result:

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

Test #62:

score: 14
Accepted
time: 42ms
memory: 39988kb

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
1557 1
1721 2
1230 3
1404 4
1157 5
1762 6
1761 7
1062 8
1622 9
1501 10
1497 11
1513 12
1580 13
1523 14
1182 15
1110 16
1333 17
1479 18
1105 19
1545 20
1502 21
1256 22
1547 23
1530 24
1507 25
1154 26
1316 27
1084 28
1384 29
1098 30
1693 31
1601 32
1964 33
1028 34
1708 3...

result:

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

Test #63:

score: 14
Accepted
time: 46ms
memory: 39056kb

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
1376 6
1551 7
1266 8
1662 9
1196 10
1839 11
1931 12
1724 13
1326 14
1173 15
1188 16
1348 17
1373 18
1714 19
1872 20
1847 21
1935 22
1864 23
1061 24
1423 25
1708 26
1132 27
1128 28
1485 29
1281 30
1416 31
1694 32
1831 33
1401 34
1555 3...

result:

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

Test #64:

score: 14
Accepted
time: 52ms
memory: 39648kb

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
1369 1
1894 2
1689 3
1666 4
1594 5
1315 6
1443 7
1572 8
1411 9
1997 10
1073 11
1172 12
1790 13
1769 14
1730 15
1397 16
1074 17
1090 18
1402 19
1934 20
1437 21
1418 22
1077 23
1885 24
1819 25
1963 26
1595 27
1565 28
1940 29
1125 30
1494 31
1454 32
1314 33
1613 34
1101 3...

result:

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

Test #65:

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

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
1131 1
1096 2
1553 3
1281 4
1286 5
1982 6
1459 7
1740 8
1261 9
1376 10
1508 11
1068 12
1657 13
1886 14
1491 15
1392 16
1051 17
1887 18
1888 19
1327 20
1680 21
1962 22
1979 23
1372 24
1277 25
1420 26
1643 27
1323 28
1919 29
1026 30
1671 31
1229 32
1926 33
1460 34
1398 3...

result:

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

Test #66:

score: 14
Accepted
time: 8ms
memory: 41124kb

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: 21ms
memory: 42828kb

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
1516 1
1747 2
1236 3
1227 4
1602 5
1599 6
1222 7
1472 8
1272 9
1199 10
1186 11
1181 12
1678 13
1843 14
1825 15
1352 16
1792 17
1403 18
1170 19
1925 20
1166 21
1163 22
1100 23
1418 24
1076 25
1082 26
1764 27
1089 28
1494 29
1092 30
1081 31
1668 32
1441 33
1117 34
1118 35
1...

result:

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

Test #68:

score: 14
Accepted
time: 39ms
memory: 39932kb

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
1200 1
1069 2
1298 3
1297 4
1686 5
1808 6
1592 7
1862 8
1348 9
1547 10
1849 11
1128 12
1221 13
1561 14
1871 15
1516 16
1693 17
1122 18
1243 19
1845 20
1797 21
1813 22
1158 23
1621 24
1005 25
1196 26
1910 27
1525 28
1528 29
1507 30
1544 31
1034 32
1716 33
1919 34
1431 3...

result:

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

Test #69:

score: 14
Accepted
time: 39ms
memory: 39468kb

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
1877 1
1646 2
1904 3
1862 4
1781 5
1261 6
1786 7
1707 8
1204 9
1265 10
1730 11
1503 12
1555 13
1418 14
1244 15
1957 16
1468 17
1791 18
1107 19
1803 20
1215 21
1967 22
1150 23
1413 24
1643 25
1991 26
1241 27
1563 28
1752 29
1539 30
1494 31
1839 32
1745 33
1770 34
1828 3...

result:

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

Subtask #8:

score: 0
Wrong Answer

Test #70:

score: 10
Accepted
time: 1286ms
memory: 202400kb

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
7871 1
7645 2
9834 3
7462 4
6305 5
9185 6
6263 7
9785 8
9099 9
6445 10
8030 11
9000 12
7822 13
9878 14
9005 15
6567 16
8984 17
9234 18
9698 19
6573 20
5600 21
6767 22
9539 23
9343 24
6506 25
5105 26
5349 27
6059 28
5718 29
6283 30
5047 31
7942 32
7558 33
7095 34
5883 ...

result:

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

Test #71:

score: 0
Wrong Answer
time: 2005ms
memory: 203128kb

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
8336 1
9478 2
9185 3
9867 4
5652 5
5205 6
9538 7
6605 8
5773 9
8399 10
6152 11
9060 12
5822 13
8863 14
9203 15
6423 16
5563 17
8692 18
6966 19
9726 20
5808 21
8615 22
9184 23
8949 24
7187 25
8561 26
6021 27
5585 28
5566 29
6889 30
5012 31
7219 32
8358 33
9762 34
7583 ...

result:

wrong answer Condition not satisfied

Subtask #9:

score: 0
Wrong Answer

Test #81:

score: 27
Accepted
time: 1197ms
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
7029 1
8311 2
9611 3
8266 4
9205 5
6226 6
5632 7
6439 8
9941 9
5363 10
6232 11
6887 12
6208 13
7996 14
7736 15
5857 16
5663 17
5225 18
7957 19
8856 20
6032 21
6914 22
8824 23
8012 24
6035 25
9044 26
6933 27
7597 28
5216 29
8792 30
8799 31
9869 32
5806 33
5943 34
6085 ...

result:

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

Test #82:

score: 0
Wrong Answer
time: 2002ms
memory: 202796kb

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
6834 1
7531 2
7709 3
7579 4
7599 5
6193 6
6279 7
9229 8
9481 9
6697 10
9675 11
6772 12
6031 13
9306 14
8211 15
6869 16
7736 17
7306 18
9348 19
9017 20
9930 21
6416 22
7281 23
7662 24
5848 25
8585 26
9977 27
7841 28
6450 29
5573 30
9534 31
5545 32
7039 33
5607 34
5787 ...

result:

wrong answer Invalid construction plan