QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#369214#7791. 通道建设 Passage Constructionzhouhuanyi63 101ms4648kbC++232.4kb2024-03-27 22:07:092024-03-27 22:07:09

Judging History

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

  • [2024-03-27 22:07:09]
  • 评测
  • 测评结果:63
  • 用时:101ms
  • 内存:4648kb
  • [2024-03-27 22:07:09]
  • 提交

answer

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<random>
#include"passageconstruction.h"
#define SN 10000
using namespace std;
mt19937 RAND(random_device{}());
const int inf=(int)(1e9);
int n,rt,smz,minn,ps[SN+1],depth[SN+1],sz[SN+1];
bool vis[SN+1],vst[SN+1];
vector<int>E[SN+1];
vector<int>p[SN+1];
vector<int>tans;
vector<pair<int,int> >ans;
void add(int x,int y)
{
	E[x].push_back(y),E[y].push_back(x);
	return;
}
void dfs(int x)
{
	for (int i=0;i<E[x].size();++i)
	{
		dfs(E[x][i]);
		if (ps[x]&&ps[E[x][i]]) ans.push_back(make_pair(ps[x],ps[E[x][i]])),ps[x]=0;
		else ps[x]^=ps[E[x][i]];
	}
	if (ps[x]) ans.push_back(make_pair(ps[x],x)),ps[x]=0;
	else ps[x]=x;
	return;
}
void dfs2(int x)
{
	vector<int>st;
	int res;
	sz[x]=vis[x];
	for (int i=0;i<E[x].size();++i) dfs2(E[x][i]),sz[x]+=sz[E[x][i]];
	if (!E[x].empty())
	{
		for (int i=1;i<=10;++i)
		{
			shuffle(E[x].begin(),E[x].end(),RAND),st.clear(),res=0;
			for (int j=0;j<E[x].size();++j)
			{
				st.push_back(E[x][j]),res+=sz[E[x][j]];
				if (res>1&&max(res,smz-res)<minn) rt=x,minn=max(res,smz-res),tans=st;
			}
		}
	}
	return;
}
void dfs3(int x)
{
	if (vis[x]) vst[x]=1;
	for (int i=0;i<E[x].size();++i) dfs3(E[x][i]);
	return;
}
void solve(vector<int>A,vector<int>B)
{
	if (B.empty()) return;
	if (A.size()==1)
	{
		for (int i=0;i<B.size();++i) E[A[0]].push_back(B[i]);
		return;
	}
	if (A.size()==2)
	{
		for (int i=0;i<B.size();++i)
		{
			if (QueryLCA({B[i]},{A[0],A[1]},A[0])[0]) E[A[0]].push_back(B[i]);
			else E[A[1]].push_back(B[i]);
		}
		return;
	}
	minn=inf,rt=0,tans.clear();
	for (int i=0;i<A.size();++i) vis[A[i]]=1;
	smz=A.size(),dfs2(1);
	vector<int>v1;
	vector<int>v2;
	vector<int>s1;
	vector<int>s2;
	for (int i=0;i<tans.size();++i) dfs3(tans[i]);
	for (int i=0;i<A.size();++i)
	{
		if (vst[A[i]]) v1.push_back(A[i]);
		else v2.push_back(A[i]);
	}
	for (int i=0;i<A.size();++i) vis[A[i]]=vst[A[i]]=0;
	vector<int>v=QueryLCA(B,v1,rt);
	for (int i=0;i<v.size();++i)
	{
		if (!v[i]) s1.push_back(B[i]);
		else s2.push_back(B[i]);
	}
	solve(v1,s1),solve(v2,s2);
	return;
}
std::vector<std::pair<int,int>>ConstructPassages(int N, const std::vector<std::pair<int,int>>&E)
{
	n=N;
	int res=0;
	for (int i=1;i<=(n<<1);++i) depth[i]=GetDistance(1,i),p[depth[i]].push_back(i),res=max(res,depth[i]);
	for (int i=1;i<=res;++i) solve(p[i-1],p[i]);
	dfs(1);
	return ans;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 3
Accepted

Test #1:

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

input:

1
1872884041
100 100 10000 10000
1
2294931821 2294931820

output:

Succeeded
0 2 0 0
2 1

result:

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

Test #2:

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

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

result:

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

Test #3:

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

input:

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

output:

Succeeded
0 4 0 0
4 2
3 1

result:

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

Test #4:

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

input:

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

output:

Succeeded
1 6 1 2
3 2
4 6
5 1

result:

ok Accepted with 1+6 operations,sum of size(s)=1+2

Test #5:

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

input:

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

output:

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

result:

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

Test #6:

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

input:

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

output:

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

result:

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

Test #7:

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

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

result:

ok Accepted with 5+10 operations,sum of size(s)=7+11

Test #8:

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

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

result:

ok Accepted with 8+10 operations,sum of size(s)=12+16

Test #9:

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

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

result:

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

Test #10:

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

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

result:

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

Subtask #2:

score: 6
Accepted

Test #11:

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

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
263 200 827 671
137 23
30 68
63 149
53 198
70 97
21 80
127 174
67 41
9 60
28 45
88 58
133 17
29 82
59 27
64 122
47 107
16 2
36 111
156 7
11 161
96 154
38 72
167 73
113 81
40 89
125 123
3 103
4 34
101 52
176 196
124 150
44 114
62 131
93 90
54 37
134 85
25 189
181 115
5 194
15 42
99 56
193 8...

result:

ok Accepted with 263+200 operations,sum of size(s)=827+671

Test #12:

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

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
261 196 889 698
72 130
13 136
82 122
113 91
90 192
26 194
117 29
116 31
163 80
112 108
44 64
147 32
4 171
141 39
23 36
191 78
128 55
28 150
17 33
5 99
14 61
63 68
92 144
179 42
12 60
195 97
70 149
27 89
181 177
172 110
34 87
170 43
146 154
21 118
24 134
157 15
155 164
140 95
105 138
106 18...

result:

ok Accepted with 261+196 operations,sum of size(s)=889+698

Test #13:

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

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
250 198 846 657
29 23
82 68
63 41
5 38
50 60
14 20
34 72
11 88
93 86
154 151
2 187
15 66
24 78
59 113
191 8
141 137
87 33
156 143
133 139
39 53
97 127
128 145
65 110
170 169
103 144
176 177
75 108
91 52
45 197
106 142
126 184
146 189
46 167
178 150
158 57
179 10
129 171
138 67
118 183
120 ...

result:

ok Accepted with 250+198 operations,sum of size(s)=846+657

Test #14:

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

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
236 198 842 629
101 102
161 120
111 182
133 134
178 109
125 145
117 112
140 105
118 132
119 30
32 80
72 184
59 5
61 110
65 188
23 38
181 94
48 86
144 121
42 166
3 195
51 149
137 139
162 126
67 11
75 124
156 68
74 12
128 127
170 154
43 13
106 24
63 84
179 2
20 169
186 100
14 62
159 28
152 1...

result:

ok Accepted with 236+198 operations,sum of size(s)=842+629

Test #15:

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

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
255 200 837 660
162 127
182 194
90 171
40 49
11 76
66 83
58 39
37 142
69 79
42 54
20 61
17 73
15 141
50 133
161 96
87 104
93 94
132 163
10 47
38 151
2 100
4 192
111 24
114 99
81 112
86 13
8 123
21 108
14 159
174 188
23 170
197 176
36 134
169 180
85 95
92 107
177 77
145 82
71 110
41 64
139 ...

result:

ok Accepted with 255+200 operations,sum of size(s)=837+660

Test #16:

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

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
249 200 816 647
108 138
146 111
126 43
13 166
193 84
117 130
147 52
132 149
156 17
45 82
200 11
131 36
140 91
33 191
106 129
144 71
46 24
139 4
55 40
28 30
143 141
50 72
112 9
70 44
61 169
119 51
75 14
151 15
12 89
183 115
41 100
18 54
133 194
158 56
168 26
155 175
171 153
2 47
142 116
123...

result:

ok Accepted with 249+200 operations,sum of size(s)=816+647

Test #17:

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

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
257 194 849 671
3 178
122 31
40 135
98 54
10 176
30 39
72 43
17 127
182 28
63 75
115 97
183 142
29 117
179 85
16 144
79 189
138 112
148 76
101 73
77 87
21 18
99 32
94 145
132 136
96 9
141 46
100 155
160 193
118 165
174 45
102 163
111 172
164 187
88 4
95 166
5 66
110 2
133 70
56 81
6 50
109...

result:

ok Accepted with 257+194 operations,sum of size(s)=849+671

Test #18:

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

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
261 196 810 672
130 44
90 179
143 153
28 25
121 84
160 138
87 176
78 55
162 94
70 71
164 177
41 47
116 79
106 48
18 61
109 139
29 154
113 145
166 132
165 193
178 183
149 99
137 173
134 45
88 53
46 192
38 27
80 156
3 57
72 2
161 133
125 108
123 155
131 170
187 174
127 128
196 182
150 115
10...

result:

ok Accepted with 261+196 operations,sum of size(s)=810+672

Subtask #3:

score: 8
Accepted

Test #19:

score: 8
Accepted
time: 2ms
memory: 4384kb

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
1087 2000 1087 2174
1855 1366
1563 1773
1275 1969
1313 1368
1409 1107
1727 1643
1837 1134
1600 1844
1114 1677
1937 1610
1588 1122
1298 1630
1755 1829
1178 1561
1357 1852
1394 1347
1054 1751
1887 1806
1266 1164
1579 1868
1609 1824
1276 1613
1078 1697
1866 1272
1554 1009
1223 1477
1214 1462
...

result:

ok Accepted with 1087+2000 operations,sum of size(s)=1087+2174

Test #20:

score: 8
Accepted
time: 2ms
memory: 4412kb

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
111 1998 111 222
728 346
13 1690
49 468
103 745
485 897
149 86
913 82
826 735
750 408
41 83
365 202
414 124
1200 301
843 283
77 694
266 156
840 789
1764 767
938 878
618 959
1564 90
20 249
51 275
994 396
1144 585
429 732
85 692
665 234
380 739
969 1630
626 449
132 884
583 558
660 1634
505 3...

result:

ok Accepted with 111+1998 operations,sum of size(s)=111+222

Test #21:

score: 8
Accepted
time: 0ms
memory: 4396kb

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
1407 1996 1407 2814
1325 1749
1702 1332
1114 1225
1984 1397
1723 1307
1737 1658
1495 1813
1051 1838
1316 1067
1922 1696
1402 1946
1355 1363
1886 1208
1247 1539
1072 1505
1700 1624
1499 1436
1498 1268
1759 1326
1659 1857
1293 1920
1651 1242
1523 1311
1751 1687
1336 1347
1810 1021
1366 1147
...

result:

ok Accepted with 1407+1996 operations,sum of size(s)=1407+2814

Test #22:

score: 8
Accepted
time: 2ms
memory: 4432kb

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
439 1996 439 878
1767 345
262 528
580 38
1719 910
1612 226
1391 1016
1557 719
431 130
1537 941
1894 322
1572 1024
1713 1082
1539 697
846 1712
1100 1898
293 1595
1970 1512
119 685
748 1521
282 245
551 419
1301 1688
857 774
488 1177
1854 1558
1950 1579
1136 576
1600 219
760 1643
167 887
1717...

result:

ok Accepted with 439+1996 operations,sum of size(s)=439+878

Test #23:

score: 8
Accepted
time: 2ms
memory: 4468kb

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
561 2000 561 1122
1367 1276
340 489
1496 602
783 21
1597 1715
994 1344
298 11
1693 1003
1737 643
709 268
552 237
1974 1391
1055 878
852 796
1345 371
209 1289
813 164
1840 1499
1960 1936
357 1188
137 1491
1488 873
279 537
724 151
1950 696
291 521
424 1920
1798 260
1166 711
1429 1638
53 280
...

result:

ok Accepted with 561+2000 operations,sum of size(s)=561+1122

Test #24:

score: 8
Accepted
time: 2ms
memory: 4632kb

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
839 1998 839 1678
837 581
427 276
84 423
90 646
277 760
687 28
530 444
5 895
21 141
497 458
564 381
237 27
271 465
293 231
808 524
79 104
301 755
596 482
390 998
147 498
351 951
283 580
754 246
60 884
647 412
402 398
817 1356
258 1915
363 645
138 662
967 953
379 324
543 567
492 494
961 556...

result:

ok Accepted with 839+1998 operations,sum of size(s)=839+1678

Test #25:

score: 8
Accepted
time: 2ms
memory: 4504kb

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
43 1996 43 86
702 874
78 412
551 608
661 662
1099 473
745 406
1850 447
28 481
746 714
411 511
738 317
949 582
825 1464
890 664
670 407
358 674
445 423
534 808
327 1963
549 360
878 219
851 860
623 665
419 533
1161 141
356 59
244 575
986 232
726 384
127 1373
915 364
806 353
654 463
785 333
7...

result:

ok Accepted with 43+1996 operations,sum of size(s)=43+86

Test #26:

score: 8
Accepted
time: 2ms
memory: 4580kb

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
1481 1998 1481 2962
233 436
55 112
711 125
874 394
419 462
171 1792
184 552
271 927
608 160
470 764
397 611
165 705
819 172
978 174
153 633
937 57
128 482
971 508
940 894
1740 34
835 314
720 261
868 801
322 751
816 628
1659 717
325 961
590 51
203 760
623 339
1905 9
120 447
181 375
880 575
...

result:

ok Accepted with 1481+1998 operations,sum of size(s)=1481+2962

Test #27:

score: 8
Accepted
time: 0ms
memory: 4436kb

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
359 1998 359 718
569 426
125 954
850 1700
743 692
195 417
668 1125
962 971
563 270
865 421
655 285
772 989
525 467
317 348
412 122
1665 59
73 633
527 62
709 671
157 558
402 156
910 918
707 886
225 799
410 613
737 738
472 115
321 795
777 159
134 263
963 362
1175 388
985 166
409 301
407 193
...

result:

ok Accepted with 359+1998 operations,sum of size(s)=359+718

Test #28:

score: 8
Accepted
time: 0ms
memory: 4492kb

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
697 2000 697 1394
707 272
433 532
900 503
486 769
264 508
252 1196
108 696
656 874
924 755
1299 878
307 439
717 17
531 89
392 247
233 987
314 719
79 47
217 660
784 151
713 669
187 615
783 73
941 633
356 908
880 789
722 378
971 26
326 241
352 69
584 683
330 1202
1729 708
447 139
760 435
860...

result:

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

Subtask #4:

score: 9
Accepted

Test #29:

score: 9
Accepted
time: 98ms
memory: 4176kb

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
2862 2000 13386 9310
795 277
258 709
1744 1169
1142 1625
1920 156
924 268
1811 510
1369 283
1444 638
1429 663
484 742
1203 1730
1786 890
1590 948
1790 525
810 998
1285 1959
1670 835
1667 758
1016 1176
1037 1466
168 967
5 586
147 821
1420 1078
1119 1627
559 763
897 502
730 65
1132 1684
1151...

result:

ok Accepted with 2862+2000 operations,sum of size(s)=13386+9310

Test #30:

score: 9
Accepted
time: 81ms
memory: 4468kb

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
2792 2000 9303 7329
1880 1985
1797 1199
1811 1790
1172 1772
1752 1980
1022 1384
1243 1322
1019 1428
1263 1182
1078 1928
1443 1465
1439 1984
1982 1518
1184 1936
1260 1542
1143 1463
1450 1055
1391 1642
1498 1442
240 301
339 619
679 866
34 865
631 99
634 414
50 15
85 629
520 317
277 49
656 99...

result:

ok Accepted with 2792+2000 operations,sum of size(s)=9303+7329

Test #31:

score: 9
Accepted
time: 100ms
memory: 4232kb

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
2879 1996 13507 9393
1196 1582
222 292
1761 187
1934 1950
1406 344
1048 373
759 851
934 438
1191 1335
1330 1389
401 179
1045 11
1426 1955
806 1459
259 50
779 1923
404 240
1023 1589
1861 1666
1615 864
1467 946
621 96
796 81
1992 1159
313 659
1059 1221
826 44
545 880
1707 1575
1792 1767
1281...

result:

ok Accepted with 2879+1996 operations,sum of size(s)=13507+9393

Test #32:

score: 9
Accepted
time: 97ms
memory: 4232kb

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
2914 1996 14114 9765
1364 152
289 17
1453 1016
1100 137
1706 49
783 63
1781 1338
1948 1809
1030 797
1700 1989
758 357
1870 448
1404 1200
1348 1904
1862 1966
1501 1445
1737 1004
1227 294
258 31
808 436
359 616
1855 1454
1730 551
1843 1687
1934 1908
1164 1629
1039 976
918 481
1494 1384
1151 ...

result:

ok Accepted with 2914+1996 operations,sum of size(s)=14114+9765

Test #33:

score: 9
Accepted
time: 94ms
memory: 4416kb

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
2869 1996 13513 9281
1712 1991
1805 1968
1140 1934
1429 1651
475 510
186 463
1525 1142
1486 1431
1707 1128
1603 241
1497 1358
1129 1345
1370 1233
1709 1762
1311 102
433 431
1950 1598
552 218
212 13
1874 1240
1685 1711
1480 1341
1750 1819
1130 1317
1000 1186
1008 659
306 1377
490 337
1145 1...

result:

ok Accepted with 2869+1996 operations,sum of size(s)=13513+9281

Test #34:

score: 9
Accepted
time: 100ms
memory: 4304kb

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
2911 2000 14600 10096
1652 1866
1285 1885
1551 465
1972 1682
323 819
1761 1919
1177 1284
1046 1701
424 931
855 165
257 807
1101 1840
1434 1622
1029 1746
1262 1049
1406 1069
1990 1366
1841 1102
410 853
1334 1230
552 318
557 475
249 604
233 473
1585 1461
1167 1857
1688 1515
287 429
897 464
1...

result:

ok Accepted with 2911+2000 operations,sum of size(s)=14600+10096

Test #35:

score: 9
Accepted
time: 93ms
memory: 4220kb

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
2904 2000 14697 10136
1796 1814
246 138
1771 363
773 656
1290 126
215 529
1007 1530
1310 847
1024 1051
1565 552
1672 1697
1693 1426
930 180
581 100
1691 1478
1573 1529
1033 184
402 182
1095 1076
1385 84
1154 1212
314 125
501 507
1135 887
673 268
1993 1395
658 64
405 729
1876 1949
1239 1623...

result:

ok Accepted with 2904+2000 operations,sum of size(s)=14697+10136

Test #36:

score: 9
Accepted
time: 92ms
memory: 4232kb

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
2905 2000 14769 10144
1364 1941
1845 637
1990 1683
969 977
119 946
386 202
1541 1310
1242 1060
1098 1028
1201 150
670 269
1379 48
1039 1520
561 979
1227 874
472 674
1740 1983
1604 740
599 785
462 311
1811 1251
1045 807
1677 1209
1244 1257
1031 1197
1019 1446
1798 1926
702 532
1095 589
1075...

result:

ok Accepted with 2905+2000 operations,sum of size(s)=14769+10144

Test #37:

score: 9
Accepted
time: 44ms
memory: 4524kb

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
2221 2000 3251 4463
1722 1701
1452 1299
1558 1942
1515 629
1659 128
1966 996
1162 1156
1521 1530
1307 1636
1550 707
1079 146
1157 1057
1499 1447
1053 1608
1298 1982
1679 1761
1347 1118
1448 1791
1718 844
1938 1864
1174 1070
1891 1622
1910 1800
1820 1434
1431 1291
1806 1880
1236 1720
1375 1...

result:

ok Accepted with 2221+2000 operations,sum of size(s)=3251+4463

Test #38:

score: 9
Accepted
time: 47ms
memory: 4264kb

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
2261 1996 3558 4561
1662 1590
1985 1370
1878 1186
1664 1215
1814 1183
1326 1292
1739 1577
1609 1466
1529 1274
1773 1711
1715 572
1030 56
1743 1161
1142 1176
1157 1431
1324 1345
1977 412
1824 189
1120 458
1930 1791
1651 1687
1881 488
1125 1764
1423 1646
1729 1910
1018 1369
1158 1443
1210 17...

result:

ok Accepted with 2261+1996 operations,sum of size(s)=3558+4561

Subtask #5:

score: 11
Accepted

Test #39:

score: 11
Accepted
time: 99ms
memory: 4228kb

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
2884 1996 13739 9466
123 679
1007 1071
306 1636
1603 463
296 656
1774 971
986 1699
864 1965
478 1000
597 1017
742 805
1708 472
1961 851
1826 804
600 844
440 13
1747 314
1381 492
1428 1568
834 1497
545 282
484 559
897 58
1740 1964
1094 1199
173 126
383 198
202 1701
81 1562
925 7
747 707
125...

result:

ok Accepted with 2884+1996 operations,sum of size(s)=13739+9466

Test #40:

score: 11
Accepted
time: 80ms
memory: 4236kb

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
2697 1998 8763 6921
312 740
472 747
538 720
34 1056
1735 90
331 282
1605 1775
102 301
31 1024
322 414
708 1371
62 859
1063 104
1662 1535
1238 1974
1513 1340
346 488
1798 341
1724 1184
1828 1674
907 1069
1681 568
1606 1767
285 1514
1269 1508
70 274
1474 1309
298 1221
1088 367
1699 103
155 4...

result:

ok Accepted with 2697+1998 operations,sum of size(s)=8763+6921

Test #41:

score: 11
Accepted
time: 59ms
memory: 4212kb

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
2393 2000 3958 4850
1103 1212
1491 1004
1387 1898
1737 1691
1624 1190
1163 1223
1362 432
1091 1515
1353 1284
1044 64
1944 1694
1522 1923
914 1931
1877 1936
481 1257
1893 1139
1666 1521
1592 1051
1343 1825
1261 1958
1804 1797
1943 1184
1985 1208
1075 1536
1953 1601
1888 1059
98 1697
1174 18...

result:

ok Accepted with 2393+2000 operations,sum of size(s)=3958+4850

Test #42:

score: 11
Accepted
time: 99ms
memory: 4228kb

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
2902 1998 13928 9653
1976 792
560 130
1297 1223
501 975
1305 706
664 928
1846 378
846 1838
233 1385
601 1848
10 455
1646 1468
1255 1072
1705 1532
1287 275
1513 683
411 1336
1913 1852
1512 1349
1883 1931
1312 1167
1991 1064
1568 1366
1267 1801
1314 1551
1023 1359
1605 1779
1855 1410
1315 14...

result:

ok Accepted with 2902+1998 operations,sum of size(s)=13928+9653

Test #43:

score: 11
Accepted
time: 99ms
memory: 4400kb

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
2893 1998 13473 9364
1270 167
41 1452
1631 1820
402 1947
1421 857
1862 681
914 620
1356 1710
1816 1442
1174 1028
171 155
808 1706
1440 785
1173 11
1196 126
1135 395
1384 1009
1880 760
49 350
1624 39
611 447
1059 975
102 29
1193 1569
1497 934
1122 698
437 1165
113 1579
266 1305
1299 149
812...

result:

ok Accepted with 2893+1998 operations,sum of size(s)=13473+9364

Test #44:

score: 11
Accepted
time: 98ms
memory: 4308kb

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
2882 2000 13290 9257
1998 818
162 498
373 844
680 689
1653 1013
481 972
587 451
292 1367
531 551
275 922
35 867
741 97
322 1386
1911 518
703 1064
1591 802
449 634
305 181
778 1906
936 974
146 811
1153 301
893 958
1415 669
889 393
224 870
1565 995
446 177
389 773
348 1507
1057 845
1980 1425...

result:

ok Accepted with 2882+2000 operations,sum of size(s)=13290+9257

Test #45:

score: 11
Accepted
time: 2ms
memory: 4388kb

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
1473 2000 1473 2946
1574 1095
1512 1281
1214 1140
1889 1248
1398 1695
1680 1976
1346 1564
1867 1874
1429 1712
1317 1578
1632 1623
1276 1501
1463 1032
1179 1903
1156 1542
1684 1866
1906 1122
1348 1831
1390 1663
1322 1561
1028 1777
1174 1170
1892 1981
1094 1059
1702 1407
1745 1188
1557 1533
...

result:

ok Accepted with 1473+2000 operations,sum of size(s)=1473+2946

Test #46:

score: 11
Accepted
time: 2ms
memory: 4312kb

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
1875 1998 1875 3750
1119 254
1348 894
140 115
382 1312
1968 1018
1197 1662
1523 1153
1223 1773
407 1100
896 1185
1752 587
231 1353
1281 156
1621 130
333 1292
1593 1990
256 1898
688 1565
1286 1564
1913 86
1317 409
142 1933
512 1884
1649 1098
742 749
1665 437
288 1924
422 997
945 1421
1447 1...

result:

ok Accepted with 1875+1998 operations,sum of size(s)=1875+3750

Test #47:

score: 11
Accepted
time: 2ms
memory: 4416kb

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
33 2000 33 66
826 15
722 1642
700 588
170 383
827 63
622 480
245 87
894 392
777 893
1295 354
364 682
365 729
519 471
780 1905
528 586
806 306
246 937
410 872
96 264
183 548
376 786
229 317
19 415
860 982
986 116
598 808
418 745
212 862
214 201
581 854
730 497
422 393
458 483
635 571
1699 2...

result:

ok Accepted with 33+2000 operations,sum of size(s)=33+66

Test #48:

score: 11
Accepted
time: 61ms
memory: 4180kb

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
2729 2000 13084 8493
522 1287
440 1951
12 1819
538 1822
718 1509
600 1735
815 1189
530 1851
845 1199
417 1003
658 1732
623 1714
931 1875
820 1520
580 1131
886 1847
246 1475
287 1032
206 1036
559 1071
378 1534
148 1968
483 1307
683 1515
667 1019
193 1059
362 1173
631 1801
680 1867
470 1860
...

result:

ok Accepted with 2729+2000 operations,sum of size(s)=13084+8493

Test #49:

score: 11
Accepted
time: 61ms
memory: 4220kb

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
2728 1998 13265 8550
405 1734
172 1311
646 1794
204 1260
266 1596
993 1110
366 1031
239 1843
468 1198
497 1523
118 1756
391 1579
506 1252
410 1838
911 1718
329 1075
777 1631
432 1989
214 1995
131 1872
568 1224
301 1844
287 1824
85 1203
174 1744
154 1304
863 1148
685 1192
194 1464
24 1628
9...

result:

ok Accepted with 2728+1998 operations,sum of size(s)=13265+8550

Subtask #6:

score: 12
Accepted

Test #50:

score: 12
Accepted
time: 101ms
memory: 4224kb

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
2758 1996 14200 9556
1863 1562
1973 1184
353 277
1638 557
783 618
1047 1680
861 919
1032 135
1970 1035
1152 100
416 1925
949 366
1041 1604
766 294
1010 1667
1049 1857
559 190
1389 483
1696 1358
923 646
1657 1958
1092 822
1383 1781
1801 1738
549 495
1807 1980
1786 1028
952 174
1697 789
273 ...

result:

ok Accepted with 2758+1996 operations,sum of size(s)=14200+9556

Test #51:

score: 12
Accepted
time: 96ms
memory: 4456kb

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
2720 1998 14432 9584
1884 79
1669 633
1894 1630
1463 86
1662 1764
662 95
602 873
692 905
1796 64
172 1587
1682 1794
1743 930
53 553
841 998
1528 611
627 610
179 1226
1539 1992
1110 1173
1047 1275
836 1164
1928 289
1799 1714
508 1191
82 1565
1053 227
556 267
1405 66
990 503
617 651
1691 373...

result:

ok Accepted with 2720+1998 operations,sum of size(s)=14432+9584

Test #52:

score: 12
Accepted
time: 55ms
memory: 4172kb

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
2294 2000 9156 6538
1637 1494
1365 1733
1396 1015
1124 1717
1222 1303
1923 1694
1338 1407
1671 1487
1527 1446
1654 1158
1736 1997
1553 1968
1572 1551
1128 1059
1740 1951
1005 1906
1599 1729
1010 1901
1805 1943
1964 1592
1159 1504
1642 1044
1246 1481
1516 923
935 992
640 922
1473 1317
1129 ...

result:

ok Accepted with 2294+2000 operations,sum of size(s)=9156+6538

Test #53:

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

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
2283 1998 7982 6161
250 185
1612 1054
1019 1629
1101 1772
1496 1320
1861 1888
1237 1556
1140 1024
1686 1886
1919 1308
1257 1402
1302 1485
1880 1666
1291 1949
1181 1965
164 706
551 354
427 718
595 651
655 798
543 621
570 244
127 490
717 604
728 727
547 257
149 697
379 502
614 990
618 454
54...

result:

ok Accepted with 2283+1998 operations,sum of size(s)=7982+6161

Test #54:

score: 12
Accepted
time: 53ms
memory: 4256kb

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
2191 1996 8950 6426
1819 1538
1762 1165
1523 1954
1577 1559
1505 1306
1598 1359
1692 1643
1551 1967
1544 1083
1936 1413
1209 1733
1455 1478
1653 1572
1920 1972
1432 1528
1061 1509
1299 1041
1683 1433
1268 1773
1471 1626
1182 1902
1814 1190
1459 1605
1084 1957
1608 1525
1673 1949
1536 1524
...

result:

ok Accepted with 2191+1996 operations,sum of size(s)=8950+6426

Test #55:

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

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
2290 2000 7845 6149
1170 1299
1439 1935
1497 1148
1341 1747
1027 1958
1511 1483
1631 1960
1967 1423
1783 1962
1185 1465
1680 1952
1357 1388
1105 1969
1455 1192
1138 1320
1160 1854
1428 1847
1328 1741
1012 1542
1938 1700
1629 1241
1144 1947
1496 1892
1612 1263
1107 1507
1638 1101
1070 1307
...

result:

ok Accepted with 2290+2000 operations,sum of size(s)=7845+6149

Test #56:

score: 12
Accepted
time: 41ms
memory: 4200kb

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
2287 1996 7216 6000
1854 1307
1090 1800
1625 1646
1354 1034
1922 1278
1937 1897
1858 1247
1954 1476
1871 1035
1031 1240
1713 1412
1232 1180
767 1990
253 760
605 961
349 692
795 839
476 407
875 178
335 290
212 654
854 343
1343 1884
1862 1653
1766 1048
1400 1817
1798 1133
1369 1093
1139 1326...

result:

ok Accepted with 2287+1996 operations,sum of size(s)=7216+6000

Test #57:

score: 12
Accepted
time: 60ms
memory: 4440kb

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
2111 1998 12606 7050
242 399
788 375
472 272
823 545
15 49
482 89
735 304
942 689
983 787
636 993
604 116
284 389
257 95
937 408
649 870
41 228
975 434
835 273
43 563
396 359
577 728
218 22
633 66
203 543
582 335
761 775
889 70
665 928
895 574
131 771
170 123
51 672
526 285
6 893
951 138
4...

result:

ok Accepted with 2111+1998 operations,sum of size(s)=12606+7050

Test #58:

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

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
1875 2000 10480 6400
126 191
987 532
914 629
768 600
745 717
24 294
236 544
655 898
475 969
12 139
786 818
388 668
337 329
862 678
318 263
364 49
731 778
86 178
537 737
881 341
46 545
396 644
51 168
499 486
859 384
334 380
292 929
298 392
11 926
806 913
835 739
264 149
790 309
604 838
387 ...

result:

ok Accepted with 1875+2000 operations,sum of size(s)=10480+6400

Subtask #7:

score: 14
Accepted

Test #59:

score: 14
Accepted
time: 99ms
memory: 4128kb

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
2711 2000 14153 9496
1483 393
673 62
840 1256
480 95
1073 380
1338 752
534 1120
232 54
1846 105
777 539
885 475
446 57
1942 45
546 714
1439 1949
1716 938
1390 1915
1192 1673
775 927
1098 1684
1486 1968
1603 1050
1092 1741
220 1000
1527 916
996 333
1885 1380
734 1899
867 1398
189 44
258 190...

result:

ok Accepted with 2711+2000 operations,sum of size(s)=14153+9496

Test #60:

score: 14
Accepted
time: 2ms
memory: 4648kb

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
821 1998 823 1642
1585 1793
1885 1955
1113 1716
1922 1910
1817 1796
1062 1426
1886 1442
1204 1633
1034 1469
1198 1780
1003 1709
1692 1238
1758 1066
1202 1774
1443 1842
1367 1507
1404 1935
1101 1221
1912 1726
1170 1455
1251 1126
1928 1265
1215 1117
1331 1225
1657 1419
1448 1566
1631 1897
14...

result:

ok Accepted with 821+1998 operations,sum of size(s)=823+1642

Test #61:

score: 14
Accepted
time: 88ms
memory: 4280kb

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
2684 2000 8728 6837
378 84
1366 999
1934 1325
813 768
1988 670
892 1712
482 328
1560 1084
713 1382
69 914
1573 142
1550 719
1681 1945
1028 1037
38 1142
1616 867
1022 1568
401 1958
815 1968
1444 854
706 1654
1388 1796
1782 415
1942 36
842 62
395 803
92 1623
1015 1548
606 333
1219 196
53 116...

result:

ok Accepted with 2684+2000 operations,sum of size(s)=8728+6837

Test #62:

score: 14
Accepted
time: 97ms
memory: 4400kb

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
2717 1996 14910 9863
785 688
1945 1442
1504 671
656 1123
1965 942
334 60
1299 644
221 1098
1886 359
1310 193
353 1706
1934 756
230 1955
1797 733
1395 920
1782 1443
721 308
698 719
1740 525
484 587
76 401
1742 851
1279 892
1089 1256
372 714
1022 166
616 1494
767 1942
462 775
840 363
1532 19...

result:

ok Accepted with 2717+1996 operations,sum of size(s)=14910+9863

Test #63:

score: 14
Accepted
time: 61ms
memory: 4240kb

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
2321 2000 9273 6949
1577 533
1997 97
767 62
422 163
1031 400
397 880
912 566
1849 1914
561 1108
1635 640
1949 1323
708 207
583 897
843 934
1080 1967
1603 1590
678 102
1033 1713
921 1550
715 965
314 748
396 1598
519 816
229 1935
610 1190
737 590
1261 1856
1233 231
418 1090
99 1079
302 233
3...

result:

ok Accepted with 2321+2000 operations,sum of size(s)=9273+6949

Test #64:

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

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
2270 1998 6829 5863
1568 108
1536 1040
1332 105
1340 1360
1396 1655
1094 615
593 1226
822 1830
94 942
225 70
989 6
1387 1113
1299 1746
379 1477
1865 521
1800 1481
1347 683
1158 1731
1441 1201
372 1397
1707 908
361 1810
1270 795
1535 114
1150 854
1239 1728
558 1853
63 1949
782 1281
547 1590...

result:

ok Accepted with 2270+1998 operations,sum of size(s)=6829+5863

Test #65:

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

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
2270 1998 6128 5984
1416 369
15 224
942 313
1802 1290
1944 1598
1392 1964
1449 1409
1234 1439
1080 1895
65 619
1476 1880
95 737
379 207
372 1260
426 1289
1827 216
974 1667
1291 106
1511 107
847 1597
603 443
840 791
1871 1479
870 1604
948 816
1628 1521
802 86
1752 586
1845 98
1677 890
1316 ...

result:

ok Accepted with 2270+1998 operations,sum of size(s)=6128+5984

Test #66:

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

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
2087 1998 12427 7015
619 834
52 117
238 262
457 519
881 118
662 176
346 103
653 358
464 137
607 356
866 936
110 68
685 214
203 683
15 696
82 669
821 927
422 121
688 529
8 781
888 614
51 401
728 56
961 170
505 338
697 57
362 337
904 367
169 312
317 890
196 572
124 263
40 580
246 329
451 142...

result:

ok Accepted with 2087+1998 operations,sum of size(s)=12427+7015

Test #67:

score: 14
Accepted
time: 55ms
memory: 4504kb

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
1901 1998 10667 6527
473 276
300 456
736 872
797 310
352 208
793 960
933 321
993 903
11 156
157 597
542 465
187 35
785 951
551 806
165 219
108 34
459 921
83 756
622 269
704 381
881 107
975 802
753 632
968 901
411 976
869 723
863 402
823 922
369 463
344 766
329 30
55 185
331 504
907 270
596...

result:

ok Accepted with 1901+1998 operations,sum of size(s)=10667+6527

Test #68:

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

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
2722 1998 13085 8360
639 1964
463 1387
324 1863
603 1955
681 1511
312 1232
519 1873
238 1056
887 1285
934 1758
33 1087
513 1698
974 1822
256 1302
400 1838
403 1390
520 1121
119 1023
221 1640
458 1048
269 1217
994 1310
623 1257
301 1471
769 1687
436 1480
814 1660
185 1304
147 1327
115 1487
...

result:

ok Accepted with 2722+1998 operations,sum of size(s)=13085+8360

Test #69:

score: 14
Accepted
time: 76ms
memory: 4188kb

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
2795 1996 12953 9144
777 1801
1618 181
1177 633
822 1611
873 1047
436 1557
44 883
953 1217
1722 21
1987 251
211 1566
299 1954
1412 989
872 1993
36 1851
877 1807
1344 580
1906 1283
734 1781
177 1045
940 1522
786 1605
486 1944
225 1460
442 1382
60 1890
677 1757
479 1958
470 1512
544 1336
169...

result:

ok Accepted with 2795+1996 operations,sum of size(s)=12953+9144

Subtask #8:

score: 0
Time Limit Exceeded

Test #70:

score: 0
Time Limit Exceeded

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:

Unauthorized output

result:


Subtask #9:

score: 0
Time Limit Exceeded

Test #81:

score: 0
Time Limit Exceeded

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
13804 10000 93172 58338
1127 1264
3765 1180
9212 9259
2367 133
5457 2380
5978 9211
1671 4914
8841 3457
9362 4036
2006 7513
1300 6878
3432 6920
6921 7281
736 4926
8088 1324
2682 659
1058 4424
4811 4505
4601 427
2068 5085
3894 865
9288 2076
2013 6933
9863 1362
6413 3880
3539 626
7369 2149
22...

result: