QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#369279#7791. 通道建设 Passage Constructionyyyyxh17 63ms49928kbC++143.7kb2024-03-27 22:58:302024-03-27 22:58:32

Judging History

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

  • [2024-03-27 22:58:32]
  • 评测
  • 测评结果:17
  • 用时:63ms
  • 内存:49928kb
  • [2024-03-27 22:58:30]
  • 提交

answer

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

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 3
Accepted

Test #1:

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

input:

1
1872884041
100 100 10000 10000
1
2294931821 2294931820

output:

Succeeded
0 0 0 0
1 2

result:

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

Test #2:

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

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

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

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

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

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

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

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

input:

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

output:

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

result:

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

Test #10:

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

input:

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

output:

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

result:

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

Subtask #2:

score: 6
Accepted

Test #11:

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

input:

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

output:

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

result:

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

Test #12:

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

input:

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

output:

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

result:

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

Test #13:

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

input:

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

output:

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

result:

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

Test #14:

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

input:

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

output:

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

result:

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

Test #15:

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

input:

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

output:

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

result:

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

Test #16:

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

input:

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

output:

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

result:

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

Test #17:

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

input:

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

output:

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

result:

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

Test #18:

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

input:

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

output:

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

result:

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

Subtask #3:

score: 8
Accepted

Test #19:

score: 8
Accepted
time: 49ms
memory: 49484kb

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: 51ms
memory: 49412kb

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

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

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: 62ms
memory: 48256kb

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: 57ms
memory: 48068kb

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: 58ms
memory: 49928kb

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: 61ms
memory: 49544kb

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: 59ms
memory: 47692kb

input:

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

output:

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

result:

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

Test #28:

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

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: 0
Runtime Error

Test #29:

score: 0
Runtime Error

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:

Unauthorized output

result:


Subtask #5:

score: 0
Runtime Error

Test #39:

score: 0
Runtime Error

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:

Unauthorized output

result:


Subtask #6:

score: 0
Runtime Error

Test #50:

score: 0
Runtime Error

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:

Unauthorized output

result:


Subtask #7:

score: 0
Runtime Error

Test #59:

score: 0
Runtime Error

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:

Unauthorized output

result:


Subtask #8:

score: 0
Runtime Error

Test #70:

score: 0
Runtime Error

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
Runtime Error

Test #81:

score: 0
Runtime Error

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:

Unauthorized output

result: