QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#118665#6629. Travelling Traderkshitij_sodani#16 894ms285184kbC++147.1kb2023-07-03 20:36:272024-05-31 18:54:53

Judging History

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

  • [2024-05-31 18:54:53]
  • 评测
  • 测评结果:16
  • 用时:894ms
  • 内存:285184kb
  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-07-03 20:36:27]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define a first
#define b second
#define pb push_back
typedef long long llo;
#define endl '\n'

vector<llo> adj[200001];
llo it[200001];
llo par[200001];
pair<llo,llo> ma={-1,-1};
void dfs(llo no,llo par2=-1,llo levv=0){
	par[no]=par2;
	levv+=it[no];
	ma=max(ma,{levv,no});
	for(auto j:adj[no]){
		if(j!=par2){
			dfs(j,no,levv);
		}
	}
}
llo dp[200001][2][2];//start with root
llo dp2[200001][2];//start with direct child or root,end with root
vector<pair<pair<llo,llo>,llo>> adj2[200001][2][2];
vector<pair<pair<llo,llo>,llo>> adj3[200001][2];
void dfs2(llo no,llo par2=-1){
	dp[no][0][0]=it[no];
	adj2[no][0][0].pb({{no,-1},-1});
	pair<llo,llo> ma={0,-1};
	pair<llo,llo> ma2={0,-1};
	dp[no][0][1]=it[no];
	adj2[no][0][1].pb({{no,-1},-1});
	dp[no][1][0]=it[no];
	//dp[no][1][1]=0;
	vector<pair<llo,llo>>  aa;
	vector<pair<llo,llo>>  bb;
	vector<pair<llo,llo>> cc;
	vector<pair<llo,llo>> dd;
	dp2[no][0]=it[no];
	dp2[no][1]=it[no];
	pair<llo,llo> maa={0,-1};
	for(auto j:adj[no]){
		if(j!=par2){
			dfs2(j,no);
			dp[no][0][1]+=it[j];
			dp[no][1][0]+=it[j];
		//	dp[no][1][1]+=it[j];
			dp2[no][0]+=it[j];
			dp2[no][1]+=it[j];

			ma=max(ma,{dp[j][1][0]-it[j],j});
			ma2=max(ma2,{dp[j][0][1]-it[j],j});
			//if(no>0){
				aa.pb({dp[j][0][1]-it[j],j});
		//	}
			bb.pb({dp[j][1][0]-it[j],j});
			cc.pb({dp2[j][1]-it[j],j});
			dd.pb({dp2[j][0]-it[j],j});
			maa=max(maa,{dp2[j][0],j});
		}
	}
	aa.pb({0,-1});
	bb.pb({0,-1});
	cc.pb({0,-1});
	dd.pb({0,-1});
	sort(aa.begin(),aa.end());
	sort(bb.begin(),bb.end());
	sort(cc.begin(),cc.end());
	sort(dd.begin(),dd.end());
	
	reverse(aa.begin(),aa.end());
	reverse(bb.begin(),bb.end());
	reverse(cc.begin(),cc.end());
	reverse(dd.begin(),dd.end());
	while(aa.size()>3){
		aa.pop_back();
	}
	while(bb.size()>3){
		bb.pop_back();
	}
	while(cc.size()>3){
		cc.pop_back();
	}
	while(dd.size()>3){
		dd.pop_back();
	}
	llo ma3=0;
	for(auto i:aa){
		for(auto j:bb){
			for(auto k:cc){
				map<llo,llo> ss;
				ss[i.b]=i.a;
				if(ss.find(j.b)!=ss.end()){
					ss[j.b]=max(ss[j.b],j.a);
				}
				else{
					ss[j.b]=j.a;
				}
				if(ss.find(k.b)!=ss.end()){
					ss[k.b]=max(ss[k.b],k.a);
				}
				else{
					ss[k.b]=k.a;
				}
				llo su=0;
				for(auto jj:ss){
					su+=jj.b;
				}
				ma3=max(ma3,su);
			}
		}
	}

	for(auto j:aa){
		for(auto k:dd){
			map<llo,llo> ss;
			ss[j.b]=j.a;
			if(ss.find(k.b)!=ss.end()){
				ss[k.b]=max(ss[k.b],k.a);
			}
			else{
				ss[k.b]=k.a;
			}
			llo su=0;
			for(auto jj:ss){
				su+=jj.b;
			}
			ma3=max(ma3,su);
		}
	}
	llo ma4=0;

	for(auto j:bb){
		for(auto k:cc){
			map<llo,llo> ss;
			ss[j.b]=j.a;
			if(ss.find(k.b)!=ss.end()){
				ss[k.b]=max(ss[k.b],k.a);
			}
			else{
				ss[k.b]=k.a;
			}
			llo su=0;
			for(auto jj:ss){
				su+=jj.b;
			}
			ma4=max(ma4,su);
		}
	}
	
	llo st=0;
	//0,1
	//1,0
	//end
	llo x,y,z;
	x=-1;
	y=-1;
	z=-1;
	llo za=0;
	for(auto i:aa){
		for(auto j:bb){
			for(auto k:cc){
				map<llo,pair<llo,llo>> ss;
				ss[i.b]={i.a,0};
				if(ss.find(j.b)!=ss.end()){
					ss[j.b]=max(ss[j.b],{j.a,1});
				}
				else{
					ss[j.b]={j.a,1};
				}
				if(ss.find(k.b)!=ss.end()){
					ss[k.b]=max(ss[k.b],{k.a,2});
				}
				else{
					ss[k.b]={k.a,2};
				}
				llo su=0;
				for(auto jj:ss){
					su+=jj.b.a;
				}
				if(su==ma3 and st==0){
					st=1;
					for(auto jj:ss){
						if(jj.b.b==0){
							x=jj.a;
						}
						if(jj.b.b==1){
							y=jj.a;
						}
						if(jj.b.b==2){
							/*if(dp2[jj.a][1]>dp2[jj.a][0]){
								za=1;
							}*/
							za=1;
							z=jj.a;
						}
					}
				}
			}
		}
	}
	for(auto j:aa){
		for(auto k:dd){
			map<llo,pair<llo,llo>> ss;
			ss[j.b]={j.a,1};
			if(ss.find(k.b)!=ss.end()){
				ss[k.b]=max(ss[k.b],{k.a,2});
			}
			else{
				ss[k.b]={k.a,2};
			}
			llo su=0;
			for(auto jj:ss){
				su+=jj.b.a;
			}
			if(su==ma3 and st==0){
				st=1;
				for(auto jj:ss){
					if(jj.b.b==1){
						x=jj.a;
					}
					if(jj.b.b==2){
						za=0;
						z=jj.a;
					}
				}
			}
		}
	}

	dp2[no][0]+=ma3;
	dp[no][0][1]+=ma.a;
	dp[no][1][0]+=ma2.a;
	
	
	for(auto j:adj[no]){
		if(j!=par2 and j!=x and j!=y and j!=z){
			adj3[no][0].pb({{j,0},0});
		}
	}
	if(x>=0){
		adj3[no][0].pb({{x,0},1});
	}
	adj3[no][0].pb({{no,-1},-1});
	if(y>=0){
		adj3[no][0].pb({{y,1},0});
	}
	if(z>=0){
		adj3[no][0].pb({{z,2},za});
	}


	llo st2=0;
	y=-1;
	z=-1;
	x=-1;
	za=0;
	dp2[no][1]+=ma4;
	if(maa.a+it[no]>dp2[no][1]){
		dp2[no][1]=maa.a+it[no];
		adj3[no][1].pb({{no,-1},-1});
		if(maa.b>=0){
			adj3[no][1].pb({{maa.b,2},0});
		}
	}
	else{
		for(auto j:bb){
			for(auto k:cc){
				map<llo,pair<llo,llo>> ss;
				ss[j.b]={j.a,1};
				if(ss.find(k.b)!=ss.end()){
					ss[k.b]=max(ss[k.b],{k.a,2});
				}
				else{
					ss[k.b]={k.a,2};
				}
				llo su=0;
				for(auto jj:ss){
					su+=jj.b.a;
				}
				if(su==ma4 and st2==0){
					st2=1;
					for(auto jj:ss){
						if(jj.b.b==1){
							y=jj.a;
						}
						if(jj.b.b==2){
							za=1;
							z=jj.a;
						}
					}
				}
			}
		}
	/*	if(st2==0){
			adj3[no][1].pb({{no,-1},-1});
			if(dd[0].a>0){
				adj3[no][1].pb({{dd[0].b,2},0});
			}
		}
		else{*/
			adj3[no][1].pb({{no,-1},-1});
			if(y>=0){
				adj3[no][1].pb({{y,1},0});
			}
			for(auto j:adj[no]){
				if(j!=par2 and j!=y and j!=z){
					adj3[no][1].pb({{j,0},0});
				}
			}
			if(z>=0){
				adj3[no][1].pb({{z,2},za});
			}
		//}
	}
	if(ma.b>=0){
		adj2[no][0][1].pb({{ma.b,1},0});
	}
	for(auto j:adj[no]){
		if(j!=par2 and j!=ma.b){
			adj2[no][0][1].pb({{j,0},0});
		}
	}
	for(auto j:adj[no]){
		if(j!=par2 and j!=ma2.b){
			adj2[no][1][0].pb({{j,0},0});
		}
	}
	if(ma2.b>=0){
		adj2[no][1][0].pb({{ma2.b,0},1});
	}
	adj2[no][1][0].pb({{no,-1},-1});
}

vector<llo> fin;
void solve(llo no,llo x=-1,llo y=-1,llo tt=0){
	if(tt==0){
		for(auto j:adj3[no][y]){
			if(j.a.b==-1){
				fin.pb(j.a.a);
			}
			else if(j.a.b==2){
				solve(j.a.a,-1,j.b,0);
			}
			else{
				solve(j.a.a,j.a.b,j.b,1);
			}
		}
	}
	else{
		for(auto j:adj2[no][x][y]){
			if(j.a.b==-1){
				fin.pb(j.a.a);
			}
			else if(j.a.b==2){
				solve(j.a.a,-1,j.b,0);
			}
			else{
				solve(j.a.a,j.a.b,j.b,1);
			}
		}
	}
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	llo n,k;
	cin>>n>>k;
	for(llo i=0;i<n-1;i++){
		llo aa,bb;
		cin>>aa>>bb;
		aa--;
		bb--;
		adj[aa].pb(bb);
		adj[bb].pb(aa);
	}
	for(llo i=0;i<n;i++){
		cin>>it[i];
	}
	if(k==1){
		dfs(0);
		cout<<ma.a<<endl;
		llo cur=ma.b;
		vector<llo> ans;
		while(cur>=0){
			ans.pb(cur);
			cur=par[cur];
		}
		reverse(ans.begin(),ans.end());
		cout<<ans.size()<<endl;
		for(auto  j:ans){
			cout<<j+1<<" ";
		}
		cout<<endl;
		return 0;
	}

	dfs2(0);

	cout<<dp2[0][1]<<endl;
	solve(0,2,1,0);
	cout<<fin.size()<<endl;
	for(auto j:fin){
		cout<<j+1<<" ";
	}
	cout<<endl;
/*	cout<<it[6]<<",,,,"<<endl;
	cout<<dp[6][1][0]<<":::"<<endl;
	cout<<dp2[2][0]<<"::"<<endl;

*/

	return 0;
}

详细

Subtask #1:

score: 2
Accepted

Test #1:

score: 2
Accepted
time: 0ms
memory: 40984kb

input:

2 1
1 2
255959470 961356354

output:

1217315824
2
1 2 

result:

ok correct!

Test #2:

score: 2
Accepted
time: 5ms
memory: 40748kb

input:

1000 1
730 89
762 280
923 523
740 22
679 350
448 769
102 712
154 965
219 32
238 289
484 502
183 311
999 682
806 450
275 101
131 197
749 720
131 937
960 202
503 320
95 262
595 133
809 560
659 451
843 218
258 842
564 316
729 727
413 237
606 531
469 258
612 8
707 539
359 680
957 639
381 708
104 490
234...

output:

95535
17
1 173 449 472 396 545 668 270 981 489 852 836 763 6 218 843 758 

result:

ok correct!

Test #3:

score: 2
Accepted
time: 66ms
memory: 48420kb

input:

200000 1
111811 133538
179217 151840
171974 117009
187613 169656
64662 13136
132434 89348
52802 175565
194821 191312
196047 99457
40339 152969
29669 180026
147677 57771
119598 58048
80707 146623
72232 101624
48109 11800
71536 69
31573 129
24409 17263
1033 148614
66977 149926
138624 87653
141889 1178...

output:

221
35
1 145832 90178 52464 3517 55709 39776 67451 59386 143855 102872 38865 13093 177086 7366 190908 160039 69864 196809 13257 612 171083 182883 14221 93359 52156 27994 103745 151704 138607 5346 14735 29598 89600 128747 

result:

ok correct!

Test #4:

score: 2
Accepted
time: 68ms
memory: 48248kb

input:

200000 1
102636 78442
179388 84484
161437 35179
102313 154299
62439 71542
176361 125315
174129 186376
180886 54947
154823 114239
174647 112385
136495 187134
157035 96260
101101 192444
58209 23947
55494 191600
168007 162648
140149 73180
130665 180633
129328 67380
90262 134914
185905 104220
111321 154...

output:

21795891322
36
1 13557 199188 104317 71891 69787 1221 63258 191536 179446 83510 187880 124824 43888 83237 194602 59080 196038 195977 18490 43421 110298 60011 137785 140692 48345 68279 128780 198550 29394 56331 112092 192199 177180 16418 142142 

result:

ok correct!

Test #5:

score: 2
Accepted
time: 79ms
memory: 48088kb

input:

200000 1
682 75953
92444 160568
113369 93705
154622 193304
149619 128186
104784 48913
131684 161196
25886 151867
89191 19511
99233 137377
104650 120096
64347 93526
111350 71598
7568 120116
123497 76821
25436 190715
99884 33654
109438 69462
165464 2475
163215 34551
33926 85078
101208 193355
50705 828...

output:

99327575017
197
1 178606 82034 53029 10508 21404 203 109187 121716 142023 3901 36728 9916 192913 18250 170199 113960 179753 163922 179588 31797 31645 183321 83207 13973 128176 38001 160968 9055 62809 168173 43933 187373 123795 114656 2192 193151 25062 141855 133596 155793 64049 57320 93903 33957 139...

result:

ok correct!

Test #6:

score: 2
Accepted
time: 63ms
memory: 49096kb

input:

200000 1
91999 92900
195726 58991
132067 99937
168188 152017
188495 19779
105961 45241
53406 75757
85118 170259
46250 47585
132248 8609
195110 32777
164307 95643
133411 739
170952 145623
19297 14414
171045 97619
74663 193421
139543 189434
36319 56453
77520 91164
91469 30021
128798 62259
183807 15271...

output:

9098893435
13
1 164355 56677 150505 174723 115829 88068 105453 199874 190131 165416 182628 114943 

result:

ok correct!

Test #7:

score: 2
Accepted
time: 63ms
memory: 48372kb

input:

200000 1
189797 1
1 148138
1 95067
141831 1
168151 1
1 25692
95612 1
1 135979
1 141581
119622 1
1 131946
86508 1
98799 1
1 189104
1 117526
46338 1
1 166375
1 28026
165221 1
54204 1
1 98743
1 181414
1 34313
1 71302
1 161200
1 146339
1 47014
1 137258
1 57857
1 196493
1 99105
54487 1
104725 1
1 45203
1...

output:

1175349557
2
1 153544 

result:

ok correct!

Test #8:

score: 2
Accepted
time: 62ms
memory: 49348kb

input:

199999 1
56367 178046
1 156890
170478 1
111308 177326
1 188427
1 90169
126610 1
161930 167698
96500 126424
118330 158517
186608 1
95505 107863
1 142887
72279 27494
1 114700
118535 1
68584 63156
97555 19966
39239 1
128030 1
1 86200
66974 1
34616 47100
173578 1
1 117279
89769 43412
1 89670
103573 1
13...

output:

2999144210
3
1 52552 129910 

result:

ok correct!

Test #9:

score: 2
Accepted
time: 110ms
memory: 60120kb

input:

200000 1
95601 67789
174512 65854
198542 123861
153390 92355
141969 168754
177054 101194
25665 15524
131869 168080
171051 30732
97293 119758
103002 59019
141990 124310
161550 116618
2585 170410
132999 38200
99202 98733
73949 155033
144918 64086
1594 34916
37138 165382
13452 170885
136973 62178
15250...

output:

200000000000000
200000
1 47213 179780 132180 145558 41335 179095 156350 24912 104386 94658 54370 97034 108043 73905 141018 157563 199841 176455 147422 87545 190562 135095 24903 62484 36389 156106 45144 120321 4911 173474 102976 13602 68252 7332 141515 59337 182112 124040 38089 15458 161370 41901 144...

result:

ok correct!

Test #10:

score: 2
Accepted
time: 89ms
memory: 54616kb

input:

200000 1
122636 169264
76896 89915
72116 125306
186356 74852
84394 177419
21725 144848
106395 111991
189102 195804
6151 170169
185460 146764
6304 149801
147880 99539
6202 175326
104277 26515
39402 33436
116555 185545
44341 92305
197925 125286
28215 102176
182103 160554
105237 169007
105618 75618
190...

output:

49951940813408
100001
1 88700 18534 14218 21693 84470 150823 121376 192964 139616 11067 93019 188349 55336 13628 87630 31553 28945 29827 140175 179655 10038 38915 99968 89953 72978 102045 45280 176852 171879 100086 93399 183932 84482 111738 112608 136016 101850 19371 96135 54333 95939 2865 140685 13...

result:

ok correct!

Test #11:

score: 2
Accepted
time: 39ms
memory: 48796kb

input:

200000 1
1 2
1 3
2 4
2 5
3 6
3 7
4 8
4 9
5 10
5 11
6 12
6 13
7 14
7 15
8 16
8 17
9 18
9 19
10 20
10 21
11 22
11 23
12 24
12 25
13 26
13 27
14 28
14 29
15 30
15 31
16 32
16 33
17 34
17 35
18 36
18 37
19 38
19 39
20 40
20 41
21 42
21 43
22 44
22 45
23 46
23 47
24 48
24 49
25 50
25 51
26 52
26 53
27 54...

output:

13954593167
18
1 2 5 10 20 40 80 161 323 647 1295 2590 5181 10363 20727 41454 82908 165817 

result:

ok correct!

Subtask #2:

score: 7
Accepted

Test #12:

score: 7
Accepted
time: 3ms
memory: 40780kb

input:

2 2
2 1
243296356 635616793

output:

878913149
2
1 2 

result:

ok correct!

Test #13:

score: 7
Accepted
time: 3ms
memory: 42768kb

input:

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

output:

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

result:

ok correct!

Test #14:

score: 7
Accepted
time: 11ms
memory: 42852kb

input:

200 2
150 170
21 33
96 152
143 26
136 70
92 159
34 164
163 182
74 115
93 61
151 83
81 119
10 146
114 170
39 83
139 4
173 41
193 96
87 57
14 164
107 51
45 15
157 17
43 183
96 30
11 137
55 18
138 81
87 12
112 122
159 82
195 185
75 71
16 191
33 88
70 195
149 114
106 160
96 118
92 44
9 141
107 143
151 2...

output:

57921623677
100
1 135 89 194 179 151 39 83 27 112 40 125 180 120 117 122 99 72 33 96 105 131 114 171 28 110 149 170 59 193 21 88 162 94 138 45 129 25 78 62 199 36 127 15 12 53 70 76 159 44 24 178 17 41 67 173 186 42 116 92 82 197 101 5 32 121 87 29 198 64 93 19 141 8 126 37 100 3 9 108 52 61 54 14 1...

result:

ok correct!

Test #15:

score: 7
Accepted
time: 0ms
memory: 40856kb

input:

200 2
33 5
171 115
70 64
38 42
123 154
167 183
152 177
36 102
98 116
125 187
61 148
143 136
62 169
102 142
86 189
115 100
85 172
136 50
158 113
133 5
10 108
90 178
90 21
127 28
122 189
115 18
83 109
197 11
53 70
191 141
166 90
70 9
74 148
160 7
186 151
197 86
147 82
107 161
122 140
110 58
179 25
107...

output:

47106979559
87
1 7 51 111 130 67 160 52 189 62 48 127 126 138 20 70 65 156 9 64 53 80 36 196 155 76 110 135 193 175 177 78 24 5 133 33 149 152 58 13 184 106 117 119 191 154 88 73 139 174 59 4 27 170 123 141 120 167 145 34 143 50 15 146 136 183 39 108 118 10 129 37 115 95 66 100 171 71 165 18 151 147...

result:

ok correct!

Test #16:

score: 7
Accepted
time: 3ms
memory: 42844kb

input:

200 2
139 197
14 69
160 138
115 60
1 141
176 33
94 88
108 26
106 20
96 60
126 180
171 110
140 91
138 63
57 183
42 62
126 163
126 64
87 167
22 142
190 112
27 120
187 109
83 111
23 196
95 47
105 177
96 170
192 113
136 188
24 198
116 137
53 177
178 38
30 158
125 64
123 132
36 114
77 192
125 165
194 7
9...

output:

73032451334
133
1 141 7 50 194 75 65 105 53 124 177 139 122 134 46 16 197 14 114 83 99 193 120 67 22 70 175 51 32 101 107 36 91 146 189 43 90 15 191 95 144 172 73 167 45 174 87 159 81 109 4 25 140 2 199 198 60 170 82 42 121 157 78 184 155 182 62 186 54 96 24 158 165 3 136 127 10 17 143 39 188 149 12...

result:

ok correct!

Test #17:

score: 7
Accepted
time: 0ms
memory: 43140kb

input:

200 2
182 43
15 179
37 173
45 38
62 4
131 151
83 188
84 58
183 148
155 59
141 133
128 19
191 170
129 87
67 156
120 199
94 11
162 27
175 86
73 50
143 94
81 103
84 120
12 19
59 38
48 34
127 41
196 87
135 69
43 119
54 176
180 112
89 60
67 117
149 18
53 61
12 1
46 67
25 38
8 52
119 51
162 197
12 31
166 ...

output:

63859058076
111
1 31 12 158 30 19 189 180 29 36 112 85 66 124 128 45 25 3 18 69 151 59 179 15 5 155 171 65 33 7 38 181 4 187 22 140 144 91 54 192 111 26 184 136 165 191 120 58 70 84 170 118 56 196 90 122 182 119 63 64 167 160 88 80 51 43 93 8 76 123 60 87 57 20 83 47 94 44 163 132 95 143 11 127 129 ...

result:

ok correct!

Test #18:

score: 7
Accepted
time: 7ms
memory: 42844kb

input:

200 2
12 76
61 106
151 109
163 180
11 135
109 179
35 199
86 104
82 109
80 70
15 123
180 154
134 91
187 81
167 4
27 71
174 101
124 127
154 29
173 175
172 61
59 109
53 55
76 55
174 67
50 169
180 32
1 182
126 3
148 146
58 127
26 181
189 47
10 156
120 112
157 149
136 166
146 122
59 17
99 136
55 138
49 1...

output:

59693686065
120
1 186 116 108 104 86 183 58 102 87 47 146 177 148 122 60 190 189 46 57 5 79 163 32 2 154 119 29 180 98 178 176 14 192 101 120 114 107 169 97 25 50 196 112 44 88 48 197 76 138 158 24 53 159 41 55 156 143 128 59 74 164 139 28 9 65 89 135 155 142 51 167 18 90 100 16 38 4 42 11 199 36 92...

result:

ok correct!

Test #19:

score: 7
Accepted
time: 7ms
memory: 40804kb

input:

200 2
33 83
16 197
177 12
71 47
85 60
34 49
96 78
30 39
63 122
95 17
168 74
89 83
62 134
45 166
48 6
178 91
151 72
153 47
104 174
86 140
33 134
24 51
129 71
48 94
141 93
64 118
155 50
43 28
182 92
31 142
105 56
156 100
83 69
179 90
140 127
186 148
16 47
175 4
123 173
27 50
154 186
107 98
200 20
66 6...

output:

61122293114
124
1 173 123 101 27 152 155 55 50 190 6 11 195 94 165 149 180 71 153 59 16 102 125 58 163 126 197 47 111 172 48 122 181 68 26 37 187 96 22 135 65 124 41 53 88 63 174 104 15 106 28 52 85 113 107 75 31 12 151 185 72 44 13 42 177 90 98 60 21 43 116 87 103 112 69 89 33 139 14 8 20 67 196 16...

result:

ok correct!

Test #20:

score: 7
Accepted
time: 3ms
memory: 42848kb

input:

200 2
91 28
137 24
181 33
82 19
90 182
180 77
2 6
190 176
100 181
13 140
52 77
85 189
28 29
176 22
7 180
55 176
99 113
6 93
28 51
117 44
180 127
114 174
102 92
13 14
129 181
80 24
95 28
181 195
162 4
28 188
55 162
59 131
47 45
145 176
136 197
145 57
159 117
143 106
192 106
126 28
43 23
51 73
109 28
...

output:

48771917800
98
1 91 29 51 95 188 109 64 79 126 135 21 166 113 99 26 46 36 130 40 104 103 28 190 22 55 145 97 12 117 11 133 62 13 63 172 198 93 102 81 84 65 17 30 59 131 37 92 6 24 151 136 8 176 82 90 160 155 69 158 106 50 125 143 192 49 165 19 129 23 48 43 181 25 96 199 132 67 41 78 71 180 52 154 13...

result:

ok correct!

Test #21:

score: 7
Accepted
time: 4ms
memory: 42908kb

input:

200 2
117 30
120 159
129 100
29 57
57 71
96 72
53 153
171 96
138 197
13 72
142 74
64 85
148 150
145 106
190 23
198 177
58 127
163 67
32 183
26 155
94 159
170 70
12 181
13 24
157 116
163 40
126 76
195 193
92 9
4 113
196 135
196 154
110 56
79 196
50 14
68 46
143 36
131 50
46 2
179 160
92 31
61 3
169 9...

output:

70064073402
147
1 197 18 165 6 168 98 180 136 122 47 121 167 103 48 138 123 104 163 73 162 81 67 21 161 174 189 119 145 170 16 193 93 175 141 8 76 63 34 159 105 44 143 172 65 36 82 94 200 126 137 155 195 70 75 106 85 43 91 190 133 148 97 41 125 56 110 111 150 160 140 23 64 37 144 100 128 7 157 182 1...

result:

ok correct!

Test #22:

score: 7
Accepted
time: 8ms
memory: 42844kb

input:

200 2
29 106
175 25
175 87
144 67
51 68
118 71
184 165
74 86
127 64
12 68
180 186
53 164
193 64
144 98
106 122
44 144
178 144
144 94
17 64
106 89
199 1
64 108
28 61
39 199
106 28
23 148
69 106
66 74
164 68
92 185
144 68
78 143
168 126
148 196
72 9
74 160
106 128
63 148
121 178
157 68
72 148
104 144
...

output:

64091222931
110
1 39 80 84 199 67 98 44 178 94 104 31 140 37 96 151 81 143 26 169 134 92 165 111 18 74 16 47 50 103 175 97 115 182 167 64 8 106 71 172 20 65 188 48 200 118 29 122 89 28 69 128 146 3 129 75 190 101 40 158 36 144 51 12 157 145 83 137 82 42 177 112 123 54 141 164 53 5 68 148 186 73 2 90...

result:

ok correct!

Test #23:

score: 7
Accepted
time: 6ms
memory: 42892kb

input:

200 2
161 12
189 84
46 61
69 75
139 170
146 21
162 91
20 125
40 78
152 25
81 140
15 138
39 184
85 183
29 59
166 126
127 24
125 56
94 26
92 37
33 196
168 16
75 64
148 57
112 142
185 46
49 195
76 18
88 79
70 125
194 136
12 154
77 195
10 2
86 155
90 170
83 67
38 179
172 175
198 191
11 51
67 42
25 93
18...

output:

82840243479
163
1 151 57 165 147 148 60 17 97 110 198 121 191 101 143 71 152 134 46 100 33 131 192 116 173 31 185 61 25 52 5 93 99 114 98 43 197 81 144 64 69 12 55 68 174 199 164 133 66 35 180 72 154 161 75 8 39 140 14 188 117 13 19 132 177 85 183 169 80 200 21 146 84 74 79 182 88 7 9 189 37 145 92 ...

result:

ok correct!

Test #24:

score: 7
Accepted
time: 0ms
memory: 43144kb

input:

200 2
19 106
54 55
83 185
106 178
78 194
51 66
133 200
106 58
106 35
163 150
50 104
96 105
124 105
41 66
124 22
54 106
27 93
106 133
196 124
58 83
106 193
124 110
194 165
150 124
194 13
42 149
127 154
121 159
106 26
100 181
124 82
1 80
177 45
69 100
54 189
61 19
70 106
134 175
168 134
6 112
44 100
1...

output:

60321563038
110
1 19 178 58 35 54 133 193 26 70 155 40 138 93 182 12 167 128 98 113 195 180 174 56 84 188 191 114 6 46 45 31 154 100 121 141 68 36 140 81 161 159 181 69 44 145 148 88 190 173 198 152 143 8 158 104 101 87 38 106 165 13 57 111 142 90 116 71 29 10 78 156 194 124 89 144 153 136 117 109 1...

result:

ok correct!

Test #25:

score: 7
Accepted
time: 4ms
memory: 42928kb

input:

200 2
104 32
163 164
138 166
140 114
144 134
193 184
94 25
196 140
119 160
29 34
170 7
175 60
122 185
85 133
9 53
95 89
171 158
34 155
67 32
73 125
167 128
27 48
157 119
105 2
13 142
134 120
71 118
66 117
182 59
156 43
84 91
126 80
55 192
34 68
64 194
131 75
81 151
117 102
145 104
99 4
3 65
91 35
79...

output:

80439812057
153
1 136 65 3 44 109 45 71 4 69 79 99 118 167 128 88 41 165 64 194 14 93 73 163 43 58 156 108 176 62 164 197 49 133 125 178 25 94 182 123 59 115 19 144 89 120 122 126 168 60 7 46 131 184 100 162 158 171 38 26 75 121 170 172 175 188 51 80 103 185 134 189 140 127 57 154 169 8 15 137 147 1...

result:

ok correct!

Test #26:

score: 7
Accepted
time: 6ms
memory: 42812kb

input:

200 2
105 64
190 149
84 15
184 93
52 80
182 129
160 51
108 184
105 167
9 77
61 80
109 84
161 188
121 2
121 20
175 60
80 154
105 88
25 60
88 10
41 123
105 135
99 184
100 98
152 105
1 75
184 199
163 102
63 88
56 184
83 13
101 123
107 50
120 42
8 78
105 45
105 121
184 92
105 129
136 124
123 139
88 19
7...

output:

51611310581
104
1 5 33 75 64 167 88 135 152 45 121 129 57 46 27 147 102 106 198 84 86 161 172 165 141 50 130 127 189 136 159 51 60 80 12 200 176 52 61 154 98 114 67 30 85 31 111 16 128 4 104 17 162 26 8 74 174 97 32 190 105 41 101 139 96 90 155 77 113 185 193 143 177 68 166 181 144 72 14 123 184 40 ...

result:

ok correct!

Test #27:

score: 7
Accepted
time: 0ms
memory: 40812kb

input:

200 2
8 1
1 22
39 1
168 1
136 1
197 1
1 142
1 4
18 1
187 1
1 74
156 1
1 94
118 1
1 86
1 76
30 1
52 1
1 42
144 1
105 1
64 1
1 9
137 1
112 1
101 1
75 1
1 113
1 164
1 29
1 60
1 167
1 135
1 192
196 1
48 1
1 179
170 1
158 1
1 145
47 1
1 98
143 1
184 1
84 1
72 1
20 1
109 1
1 106
1 3
1 79
55 1
1 77
102 1
1...

output:

89576768884
200
1 8 22 39 168 136 197 142 4 18 187 74 156 94 118 86 76 30 52 42 144 105 64 9 137 112 101 75 113 164 29 60 167 135 192 196 48 179 170 158 145 47 98 143 184 84 72 20 109 106 3 79 55 77 102 126 7 138 175 120 115 17 159 63 161 181 163 6 70 23 176 93 38 173 160 5 125 186 153 26 28 46 189 ...

result:

ok correct!

Test #28:

score: 7
Accepted
time: 4ms
memory: 42908kb

input:

199 2
1 106
198 165
176 34
59 39
1 34
151 36
78 85
1 109
48 4
1 13
165 1
73 163
159 126
150 106
1 33
82 103
17 180
1 151
46 87
1 111
195 1
1 164
25 23
135 161
1 107
1 2
11 58
97 1
170 1
71 57
72 157
1 158
1 186
153 1
1 60
29 1
27 52
50 1
162 122
64 1
95 1
1 75
160 142
134 81
77 155
79 1
1 119
30 169...

output:

101902858721
102
1 121 181 106 34 109 13 165 33 151 111 195 164 107 2 97 170 158 186 153 60 29 50 64 95 75 79 119 157 120 132 128 183 77 90 144 35 168 141 83 45 103 184 161 126 171 99 18 48 180 174 163 118 160 78 112 169 96 52 193 134 136 67 140 69 137 20 76 23 89 162 91 190 56 93 125 177 80 84 131 ...

result:

ok correct!

Test #29:

score: 7
Accepted
time: 3ms
memory: 42892kb

input:

197 2
24 1
65 24
129 58
92 96
61 1
42 18
95 3
167 168
147 110
2 172
143 156
115 110
1 67
158 127
99 134
126 89
30 95
85 13
1 149
128 106
81 118
137 100
146 88
105 1
76 105
153 9
96 123
67 49
61 186
1 9
120 46
51 79
79 1
77 195
17 11
117 7
114 106
135 21
59 1
100 122
179 67
158 184
16 83
96 1
191 75
...

output:

55959842378
56
1 133 78 181 23 24 61 67 149 105 9 79 59 96 121 110 10 100 75 126 158 42 143 88 93 188 13 169 16 53 29 167 46 17 108 182 58 7 197 187 2 118 36 99 21 40 106 162 195 90 95 161 32 97 107 163 

result:

ok correct!

Test #30:

score: 7
Accepted
time: 3ms
memory: 43060kb

input:

196 2
83 40
1 26
46 179
44 181
73 123
46 128
150 168
150 151
134 48
91 48
47 79
161 46
114 35
120 35
183 48
47 66
154 69
150 45
74 40
32 63
48 1
22 18
41 26
1 46
78 47
88 40
152 47
191 44
60 46
57 48
67 73
150 38
48 10
126 89
44 23
44 56
31 126
196 150
80 35
46 25
129 32
20 22
75 44
73 145
170 154
2...

output:

26055322292
42
1 63 129 158 65 54 5 8 37 111 2 102 106 189 193 32 26 48 46 154 126 35 22 44 47 73 40 150 168 151 45 38 93 135 98 166 104 15 115 109 124 196 

result:

ok correct!

Test #31:

score: 7
Accepted
time: 4ms
memory: 40992kb

input:

200 2
119 95
47 18
176 194
73 36
90 105
24 29
79 39
53 98
130 111
42 125
158 15
100 60
128 149
76 41
134 1
108 2
94 157
196 43
145 100
11 9
144 175
37 40
5 120
49 117
165 134
158 84
142 51
82 167
157 108
175 161
50 22
177 35
95 118
77 116
33 131
194 27
116 128
189 72
28 192
130 112
26 4
187 121
97 4...

output:

200000000000
200
1 134 165 110 89 187 121 78 61 122 9 11 173 186 56 30 20 74 69 168 6 93 198 12 191 144 175 161 32 79 39 8 27 194 176 113 148 10 52 150 181 124 99 57 73 36 13 88 192 28 23 183 15 158 84 70 71 166 188 151 140 169 98 53 64 139 43 196 50 22 87 54 156 162 109 189 72 199 159 179 25 40 37 ...

result:

ok correct!

Test #32:

score: 7
Accepted
time: 6ms
memory: 45268kb

input:

200 2
7 176
162 197
197 66
22 23
177 157
49 22
65 171
119 124
155 193
15 41
34 105
61 102
126 31
36 195
14 192
173 57
75 4
104 174
141 20
185 123
199 145
18 9
110 200
148 9
90 137
35 19
106 139
150 172
91 47
168 180
104 70
169 200
161 66
129 114
66 118
71 200
160 133
31 196
36 11
195 49
112 51
22 15...

output:

99918618520
200
1 189 171 65 102 165 61 24 199 191 145 183 34 105 90 81 137 56 172 150 124 40 119 68 170 76 72 74 73 135 36 11 195 6 49 198 22 151 23 55 188 94 47 109 91 149 60 159 173 77 57 154 19 35 120 83 86 52 114 129 63 13 106 33 139 89 133 108 160 184 103 100 194 37 38 134 193 155 152 136 64 2...

result:

ok correct!

Test #33:

score: 7
Accepted
time: 0ms
memory: 42884kb

input:

200 2
108 103
141 45
176 16
96 38
130 106
18 176
61 23
38 22
154 198
83 123
77 52
102 188
133 125
123 116
120 45
164 195
174 48
163 54
74 31
199 175
79 110
137 173
182 153
22 1
65 54
60 16
187 144
45 188
99 152
17 118
64 118
75 163
74 141
181 184
39 175
172 117
118 100
138 164
172 99
52 162
200 80
1...

output:

97817235416
200
1 131 6 72 22 55 76 3 38 96 111 135 48 66 112 192 174 68 85 14 23 61 127 2 99 152 149 37 172 117 168 40 19 193 63 57 144 187 78 178 180 84 165 122 62 47 151 15 200 80 114 166 16 60 128 160 176 18 169 24 73 93 90 105 134 58 177 5 103 108 179 10 133 125 97 159 139 140 183 98 118 17 64 ...

result:

ok correct!

Test #34:

score: 7
Accepted
time: 4ms
memory: 42944kb

input:

200 2
185 93
20 134
91 82
108 129
123 164
104 56
146 113
110 5
83 87
106 63
67 199
41 108
114 133
172 99
57 132
46 199
32 45
170 191
123 200
53 141
124 186
44 162
65 159
85 195
196 19
7 134
64 35
88 58
23 28
30 20
76 11
176 167
36 124
88 148
175 29
31 151
128 4
103 171
50 79
71 127
84 8
36 4
175 109...

output:

92546968269
200
1 70 137 78 161 40 147 179 109 33 56 104 175 86 111 29 14 72 153 177 168 83 197 87 73 38 146 113 67 65 126 159 199 13 66 46 16 18 122 62 51 80 181 74 171 98 125 103 188 55 85 195 20 6 160 30 134 35 116 64 7 68 99 172 102 71 118 127 136 52 101 120 157 22 176 167 91 48 144 193 82 156 1...

result:

ok correct!

Test #35:

score: 7
Accepted
time: 4ms
memory: 42864kb

input:

200 2
186 20
197 94
138 143
75 2
6 102
114 98
195 131
151 62
33 77
85 149
158 164
30 38
21 93
177 133
72 188
145 52
68 176
194 57
118 103
91 112
178 81
63 169
31 155
92 133
29 166
99 15
65 75
159 147
79 55
45 23
139 180
38 119
3 75
114 127
117 112
146 161
99 48
37 132
148 193
178 179
71 116
140 11
1...

output:

82875113284
152
1 75 103 118 35 3 64 33 183 150 113 184 46 96 19 191 182 5 157 49 37 175 132 115 84 57 161 86 53 146 119 136 16 141 105 142 38 12 151 62 40 47 30 11 102 160 6 140 27 55 167 120 50 79 83 131 67 90 22 195 130 23 68 176 101 185 61 158 116 154 71 124 156 171 152 129 56 174 92 169 177 123...

result:

ok correct!

Test #36:

score: 7
Accepted
time: 4ms
memory: 42908kb

input:

200 2
140 198
32 90
73 76
75 155
54 65
192 80
60 37
103 28
120 118
87 118
174 30
174 191
156 138
187 47
200 17
106 179
80 2
137 71
18 75
146 80
53 153
128 82
31 89
180 110
36 82
129 186
180 36
125 53
31 94
124 189
133 83
151 94
175 48
172 97
34 74
64 87
157 139
155 9
33 126
90 160
199 48
25 86
156 2...

output:

79408775618
143
1 140 129 143 91 136 186 130 76 62 158 145 132 92 164 53 189 194 124 154 125 68 16 86 46 25 23 141 40 89 94 152 151 127 31 65 190 134 197 147 184 54 38 139 74 84 34 70 66 166 60 83 183 88 111 133 52 174 165 176 56 77 10 55 99 168 169 13 114 135 96 90 200 182 17 8 14 167 48 126 50 33 ...

result:

ok correct!

Test #37:

score: 7
Accepted
time: 3ms
memory: 42900kb

input:

200 2
1 2
1 3
2 4
2 5
3 6
3 7
4 8
4 9
5 10
5 11
6 12
6 13
7 14
7 15
8 16
8 17
9 18
9 19
10 20
10 21
11 22
11 23
12 24
12 25
13 26
13 27
14 28
14 29
15 30
15 31
16 32
16 33
17 34
17 35
18 36
18 37
19 38
19 39
20 40
20 41
21 42
21 43
22 44
22 45
23 46
23 47
24 48
24 49
25 50
25 51
26 52
26 53
27 54
27...

output:

31861270500
55
1 7 6 27 26 106 107 53 52 13 12 3 2 8 9 39 38 152 153 76 77 19 18 4 5 22 23 94 95 191 190 47 46 11 10 40 41 166 167 83 82 20 21 85 84 169 168 42 43 174 175 87 86 172 173 

result:

ok correct!

Test #38:

score: 7
Accepted
time: 4ms
memory: 41008kb

input:

200 2
1 2
1 3
1 4
2 5
2 6
2 7
3 8
3 9
3 10
4 11
4 12
4 13
5 14
5 15
5 16
6 17
6 18
6 19
7 20
7 21
7 22
8 23
8 24
8 25
9 26
9 27
9 28
10 29
10 30
10 31
11 32
11 33
11 34
12 35
12 36
12 37
13 38
13 39
13 40
14 41
14 42
14 43
15 44
15 45
15 46
16 47
16 48
16 49
17 50
17 51
17 52
18 53
18 54
18 55
19 56...

output:

26748477707
43
1 11 13 12 104 105 106 35 36 37 4 3 2 18 19 17 152 153 154 51 50 52 6 7 5 47 48 49 148 146 147 16 14 15 134 135 136 45 46 44 131 132 133 

result:

ok correct!

Subtask #3:

score: 3
Accepted

Dependency #2:

100%
Accepted

Test #39:

score: 3
Accepted
time: 12ms
memory: 41692kb

input:

2000 2
1653 466
455 1262
319 394
823 998
1135 313
244 809
563 850
1865 1303
609 1531
302 1084
504 163
1475 1799
534 258
1597 413
1161 330
676 1694
1315 1619
1646 32
1629 161
280 1765
102 877
474 503
1162 491
1182 1505
532 1820
525 1836
1682 808
1026 80
809 1334
1376 1783
401 708
1323 1443
1242 1215
...

output:

176031446963
333
1 1438 239 459 410 1805 937 1479 605 1216 1325 313 1818 198 242 126 423 1142 1101 438 838 467 512 1133 1471 872 375 783 1912 915 1100 1719 435 877 142 1892 334 325 632 457 1411 658 1284 525 482 287 18 374 82 1574 1003 1870 1452 1046 148 1208 338 660 326 1766 1919 652 97 1726 1161 15...

result:

ok correct!

Test #40:

score: 3
Accepted
time: 8ms
memory: 43472kb

input:

2000 2
892 750
281 1593
1698 1268
1500 653
348 1393
1617 797
1044 680
1517 1883
1081 1003
293 948
412 478
1733 690
1785 1377
1902 1304
1674 1565
1350 131
242 573
1778 275
296 1177
1090 1862
1503 1175
1620 207
1441 323
181 449
219 1911
671 1713
606 1360
1558 834
562 1576
1212 1077
257 1606
790 1496
1...

output:

202483759818
403
1 25 186 1506 1577 563 629 762 1100 1452 687 801 381 1190 1638 36 1952 560 1098 1461 108 668 1095 787 1726 1042 1068 915 1569 772 430 1572 552 1384 348 1157 1393 784 1197 553 650 1680 1868 1787 691 1462 1287 1437 1798 1775 897 808 1586 1729 1199 524 999 439 1196 1792 565 1478 1596 9...

result:

ok correct!

Test #41:

score: 3
Accepted
time: 10ms
memory: 45564kb

input:

2000 2
1581 867
670 1948
1286 1189
292 1357
1538 951
691 1646
502 1385
1071 812
482 469
1853 1303
614 774
363 62
506 91
718 951
1327 306
170 23
128 495
1841 263
178 588
271 252
930 1147
552 1150
1550 1584
685 1699
405 1353
1948 510
1632 327
1854 1167
1327 591
112 800
482 305
598 7
922 1645
1737 1811...

output:

184825610246
359
1 172 394 1959 1661 1191 1453 241 1811 1449 415 1773 934 13 1737 1304 59 1621 1152 323 924 670 598 1810 1558 324 936 510 931 158 1860 827 1630 1952 247 805 574 697 1491 1377 1484 1609 1042 336 1595 254 647 1891 1948 1781 86 1041 90 1060 1032 58 3 992 1770 1641 1124 839 1655 45 1711 ...

result:

ok correct!

Test #42:

score: 3
Accepted
time: 12ms
memory: 41356kb

input:

2000 2
1217 1905
1210 453
765 261
1635 1637
1867 1564
1876 1141
1867 283
1093 1385
677 1050
284 1377
228 1393
541 1985
884 242
1714 1304
118 15
1992 1098
449 181
1549 246
84 1198
913 1522
666 1685
1704 263
589 1407
1870 906
1411 561
1252 562
282 17
1137 372
764 1171
1721 172
1990 1755
1231 1948
201 ...

output:

222905521782
416
1 1544 1036 1655 549 1787 1958 1080 830 763 1901 1414 1617 189 561 1647 1290 982 1694 470 1932 1012 695 1411 1371 620 434 602 593 1986 813 257 83 1085 1457 100 1733 1899 1322 1974 1011 1554 1994 970 818 14 1340 1403 5 1213 687 1305 193 1072 1171 372 215 1043 1422 683 141 1970 1511 1...

result:

ok correct!

Test #43:

score: 3
Accepted
time: 14ms
memory: 43516kb

input:

2000 2
989 1552
460 285
670 1653
190 1210
736 941
1555 647
648 363
1500 1908
241 1143
1702 1181
266 1622
409 955
1442 1033
1236 447
194 1312
463 1304
1994 397
835 564
22 982
1214 562
813 1812
1396 783
191 1449
1760 691
103 1289
493 439
333 1401
283 884
1419 832
1561 277
1582 294
1183 925
7 529
191 1...

output:

176264452857
344
1 1542 146 397 680 376 1823 469 1994 1497 527 309 1688 1734 1766 384 618 30 4 742 22 1684 604 982 943 1136 1595 940 1798 1302 959 776 733 1758 1547 143 554 144 685 1723 1333 339 1299 1086 682 353 1166 1517 1783 657 531 343 1594 1241 662 129 96 190 1300 1487 1733 1597 522 510 857 467...

result:

ok correct!

Test #44:

score: 3
Accepted
time: 10ms
memory: 43496kb

input:

2000 2
1900 687
259 1748
582 1542
1844 470
1752 1845
202 37
1206 807
646 269
1687 681
1482 1630
930 446
391 617
1424 1798
1481 1762
820 295
1263 1766
474 210
372 1407
117 1854
199 216
1779 789
937 555
1494 1909
1824 1319
1001 1938
144 45
785 196
1135 636
390 1866
1404 206
1790 524
1734 663
1604 1767...

output:

362696256044
704
1 1488 461 1747 1736 1234 1316 324 1677 1366 1981 819 1350 448 1561 1149 831 1933 1698 1974 527 796 951 218 1450 869 1398 1069 920 1723 361 911 455 826 1188 1273 1363 1787 519 207 1493 55 1826 1567 1419 629 1646 125 697 1639 85 241 506 1759 862 651 159 1514 372 1964 1407 1572 1466 7...

result:

ok correct!

Test #45:

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

input:

2000 2
284 498
512 963
418 534
206 1186
1506 1397
1511 459
992 742
1644 1013
1474 1397
1942 1941
1673 1229
1384 442
1397 1756
1876 280
2000 1932
1397 1993
1217 1474
1774 1204
737 1785
1356 1384
1473 1116
2000 1812
1617 1739
17 1979
229 1979
723 492
621 227
358 550
206 376
440 1675
1393 1790
909 341
...

output:

203246075730
402
1 532 1248 1778 1610 423 1886 988 1047 1672 1192 104 15 87 437 810 1055 1619 1470 927 140 932 1606 1331 1737 686 362 1811 530 277 477 1004 1239 1467 1608 1009 701 468 1488 847 1961 1648 1142 812 378 454 1255 1084 1771 1638 1048 906 347 440 417 1426 1432 193 1861 487 819 411 108 7 12...

result:

ok correct!

Test #46:

score: 3
Accepted
time: 9ms
memory: 43584kb

input:

2000 2
1237 1826
571 1212
1932 1106
88 1218
764 916
1880 854
700 1803
585 679
891 1587
712 1921
233 738
668 1927
1167 918
432 1789
1377 1585
1344 916
692 1546
1749 1947
1571 1869
1484 1846
1531 1997
694 1957
758 567
1649 181
3 1062
987 1320
533 1487
1402 1085
936 1807
1526 752
183 1513
403 187
1796 ...

output:

404938855945
815
1 1556 348 1319 279 523 727 634 1272 755 175 1938 886 1429 1315 952 1840 1914 1416 1716 1544 287 938 1967 399 1799 370 178 1304 1375 210 364 392 535 1522 1343 1002 339 383 152 1637 812 796 200 613 1311 1793 198 121 1626 442 1043 734 1957 1723 581 911 1452 58 262 887 231 1194 846 258...

result:

ok correct!

Test #47:

score: 3
Accepted
time: 9ms
memory: 41680kb

input:

2000 2
593 1134
610 1128
274 1314
1799 123
1738 1823
523 1117
1272 529
1439 225
1275 450
286 1117
34 365
935 1460
1200 1008
475 1622
854 819
1632 890
996 1743
237 1665
1669 1985
1767 1934
1799 783
12 1601
342 1623
924 144
1269 146
1799 340
1280 1669
1270 1128
950 1245
1686 1730
1117 1202
178 393
180...

output:

273811282141
553
1 1288 627 1219 1386 403 1720 1169 1791 1744 766 1344 1524 1976 1501 968 317 70 729 912 1142 1685 1332 226 641 1018 795 1380 334 573 602 1126 1348 435 1793 1617 129 812 577 903 1162 1051 1559 1748 52 438 199 582 1000 181 493 674 1969 967 592 1337 407 1743 237 1910 1296 225 1998 1439...

result:

ok correct!

Test #48:

score: 3
Accepted
time: 9ms
memory: 43432kb

input:

2000 2
1383 1
1 1410
1 1106
1154 1
1 1202
1794 1
1512 1
1744 1
221 1
1 917
1637 1
1 118
1 423
164 1
1 1881
479 1
1 1029
1 567
1 193
1 1364
1 45
1458 1
692 1
1765 1
807 1
897 1
43 1
1243 1
1 681
1272 1
1 579
122 1
1 1241
1299 1
1558 1
1 88
726 1
1 654
1900 1
1895 1
1 384
1 661
223 1
1 956
1 1112
38 1...

output:

981828873758
2000
1 1383 1410 1106 1154 1202 1794 1512 1744 221 917 1637 118 423 164 1881 479 1029 567 193 1364 45 1458 692 1765 807 897 43 1243 681 1272 579 122 1241 1299 1558 88 726 654 1900 1895 384 661 223 956 1112 38 1213 1492 1768 969 633 418 172 769 375 558 1620 196 1704 178 1057 1692 313 853...

result:

ok correct!

Test #49:

score: 3
Accepted
time: 11ms
memory: 43596kb

input:

1999 2
1 1197
761 1416
1 1777
1341 30
1 791
966 1025
1 890
1103 1
1195 1929
342 1
219 1
993 553
1 1308
392 726
993 1
1747 777
840 1
1 1977
916 1
1 8
1 447
1125 1740
493 1153
781 762
1 435
1 1939
1965 1030
1 812
1 1962
162 1568
793 82
1208 1087
938 1
1 1512
480 1361
1 957
636 816
56 1585
1 822
1018 1...

output:

1001116296577
1002
1 289 1322 1197 1777 791 890 1103 342 219 1308 993 840 1977 916 8 447 435 1939 812 1962 938 1512 957 822 1018 1700 539 694 430 1803 648 457 1202 792 318 222 1622 1140 1261 1670 141 1052 132 381 1282 476 613 464 462 731 102 405 181 850 971 966 1677 1005 1705 249 1524 1895 1298 1435...

result:

ok correct!

Test #50:

score: 3
Accepted
time: 8ms
memory: 43468kb

input:

1997 2
1471 500
206 950
1847 634
897 1
1227 1
435 1540
1020 5
1058 1810
888 1947
1504 1339
1899 986
1647 1604
1 1836
997 261
1349 1153
965 1
429 1
4 1133
1154 259
1993 1
1760 609
8 1
1 1639
1114 1901
1888 971
969 706
1910 875
1561 1888
1118 40
1 372
860 1849
1 1784
1 330
1521 1951
1354 6
1798 375
12...

output:

505561828143
506
1 1570 841 1648 776 897 1227 1836 965 429 1993 8 1639 372 1784 330 1205 1937 303 1720 1138 1069 1011 342 1431 1244 976 1663 451 1875 915 1974 690 215 1812 1175 442 1066 1470 997 594 1644 1277 1504 1641 634 1763 766 98 138 1828 410 1493 859 1319 546 1581 1206 1073 1108 1085 1302 547 ...

result:

ok correct!

Test #51:

score: 3
Accepted
time: 4ms
memory: 43528kb

input:

1936 2
91 782
1865 1244
427 448
1608 1299
1644 880
5 1509
232 1110
1515 1927
1257 448
1217 1331
1 363
1131 1217
1849 1608
1928 249
482 1384
445 682
274 1075
1283 508
1515 1189
1250 1588
529 1158
1833 1217
1064 968
1746 948
264 1509
1369 92
1865 1395
1369 1312
969 1109
1895 333
955 682
1291 275
1369 ...

output:

72540612666
132
1 445 955 1659 1300 1742 1884 536 904 1205 1400 1620 701 941 793 1560 1867 673 135 961 1816 219 1118 1005 1581 1346 1022 1734 248 1281 1224 1219 276 1516 420 1016 1520 905 1344 1387 145 1241 778 1500 1910 682 363 232 968 1202 621 679 1509 428 1369 1217 1928 91 76 1746 1644 747 320 90...

result:

ok correct!

Test #52:

score: 3
Accepted
time: 4ms
memory: 43100kb

input:

2000 2
1142 984
741 1666
929 727
870 1390
111 797
486 816
974 1047
1836 1891
1942 1457
1730 1121
784 1586
881 1069
809 1611
1749 1483
269 1298
1435 1988
59 549
1663 1161
526 1785
445 1934
1604 562
1494 1070
334 332
1028 723
574 1933
1676 1670
1316 1613
1055 490
1321 1549
1374 83
23 497
796 210
728 1...

output:

2000000000000
2000
1 898 163 862 1352 1782 1563 156 1614 1132 788 356 48 7 1167 1084 921 142 1378 1800 634 1490 1514 855 286 387 1743 1569 998 319 1749 1483 1181 1515 1784 1253 540 1973 650 1862 1144 228 1892 939 216 71 764 725 1876 265 192 1986 1954 868 1416 1387 574 1933 1596 950 1909 16 58 1852 1...

result:

ok correct!

Test #53:

score: 3
Accepted
time: 7ms
memory: 42560kb

input:

2000 2
450 1099
1291 492
1509 508
1606 702
1878 729
1405 58
430 1790
829 737
1424 1560
488 1944
1366 1611
128 607
1935 477
1364 1359
1964 578
471 1112
995 420
405 340
1058 1297
526 1263
527 1557
512 1599
1012 1340
1776 558
1202 1515
1835 277
1219 1610
898 116
625 1123
232 1492
1780 71
722 1280
177 6...

output:

1010476018711
2000
1 1762 360 555 654 582 743 1537 679 1794 312 404 1178 1338 228 1167 1651 187 484 1974 572 303 1706 1176 1984 1160 727 297 997 597 279 1995 1823 322 783 800 1012 827 1340 1285 239 61 1725 347 1813 962 692 9 624 1037 1671 1181 1997 1224 1249 1640 1989 1528 1679 633 525 1874 1910 370...

result:

ok correct!

Test #54:

score: 3
Accepted
time: 10ms
memory: 42156kb

input:

2000 2
1280 733
1348 842
180 1085
492 865
1924 698
646 249
1106 232
1819 1637
1785 585
673 460
799 1613
955 1512
781 1331
1926 699
518 1314
240 433
1217 346
1819 628
140 1858
1910 854
588 1031
231 582
718 230
1600 1880
1304 471
655 1330
1817 1233
1297 304
1466 113
518 465
14 141
1653 506
31 1557
199...

output:

994437083657
2000
1 1987 1012 982 351 1310 725 54 1698 562 1277 978 238 658 874 329 722 179 1675 153 1396 357 275 1481 36 1250 319 432 1790 1928 644 182 1221 143 1224 227 1320 201 1302 1293 757 1787 1032 425 472 297 1681 1838 1649 1442 980 1872 1181 1231 903 1395 1431 973 1341 167 1915 1739 846 954 ...

result:

ok correct!

Test #55:

score: 3
Accepted
time: 15ms
memory: 45964kb

input:

2000 2
1033 409
609 267
1734 507
588 1257
112 1620
844 1436
25 599
36 324
583 163
922 286
67 268
1767 720
961 1569
553 239
99 1795
1391 1138
689 1452
1250 953
1260 1794
251 1788
1891 1726
1414 77
689 810
42 389
1688 1957
1799 892
798 1790
612 927
999 582
566 879
1603 741
1153 1356
1998 1288
1993 151...

output:

1011568611012
2000
1 573 690 1630 29 1069 1308 271 1605 223 1388 957 1513 826 1223 1700 672 59 1158 1682 495 576 1015 900 1787 858 1245 366 1001 217 1741 33 1797 219 1397 1471 444 438 1731 1501 911 776 1808 1295 1572 944 1085 1186 708 65 1286 1109 553 1067 1739 239 297 959 1892 542 1565 979 1494 112...

result:

ok correct!

Test #56:

score: 3
Accepted
time: 13ms
memory: 41928kb

input:

2000 2
1213 910
748 565
244 1508
69 1383
1066 1452
1470 20
953 273
926 226
1647 1709
378 1921
1809 1976
1714 1640
1273 1888
1243 591
1277 1937
416 491
1360 367
242 131
819 192
307 1792
1497 317
1710 1547
129 55
457 1380
1046 1331
1397 954
740 1994
1388 1649
819 312
1168 694
713 914
1917 928
979 1671...

output:

804671840202
1502
1 95 1136 1846 400 1915 98 1029 335 1756 1576 511 102 865 1265 1997 1363 589 345 850 1285 464 343 190 719 352 434 1808 383 1909 695 172 414 985 704 1863 1347 487 249 1204 1045 948 1836 851 1542 1405 558 217 1875 1792 1337 1231 135 488 219 587 1717 1676 1642 947 1381 933 372 974 89 ...

result:

ok correct!

Test #57:

score: 3
Accepted
time: 17ms
memory: 41544kb

input:

2000 2
583 1761
646 880
265 1017
669 1241
1606 1517
1791 1712
1199 1024
1939 161
1888 1095
1127 1892
169 1741
1411 627
1932 709
201 1642
1695 1359
1853 34
1597 1117
1629 907
392 1684
247 32
75 1518
1990 1150
1465 878
304 186
288 432
49 1221
406 1738
99 191
1125 1264
903 1572
1493 1804
1783 1402
645 ...

output:

771091486166
1403
1 656 91 1915 1748 1340 723 736 812 1804 1826 1493 999 672 1710 275 98 1833 1490 1368 31 1255 1990 172 1752 1737 842 1225 1741 444 1296 674 248 594 1980 169 331 1437 847 721 182 1104 1089 188 36 1859 1196 852 1170 668 1888 1402 1783 329 1438 1095 308 910 1439 1943 18 437 1295 1775 ...

result:

ok correct!

Test #58:

score: 3
Accepted
time: 7ms
memory: 43540kb

input:

2000 2
1 2
1 3
2 4
2 5
3 6
3 7
4 8
4 9
5 10
5 11
6 12
6 13
7 14
7 15
8 16
8 17
9 18
9 19
10 20
10 21
11 22
11 23
12 24
12 25
13 26
13 27
14 28
14 29
15 30
15 31
16 32
16 33
17 34
17 35
18 36
18 37
19 38
19 39
20 40
20 41
21 42
21 43
22 44
22 45
23 46
23 47
24 48
24 49
25 50
25 51
26 52
26 53
27 54
2...

output:

73323472678
111
1 4 5 20 21 85 84 339 338 1354 1355 677 676 169 168 42 43 10 11 2 3 14 15 61 60 243 242 968 969 1939 1938 484 485 121 120 30 31 7 6 26 27 111 110 441 440 1762 1763 881 880 220 221 55 54 13 12 50 51 207 206 825 824 1649 1648 412 413 103 102 25 24 97 96 387 386 1546 1547 773 772 193 19...

result:

ok correct!

Test #59:

score: 3
Accepted
time: 13ms
memory: 43376kb

input:

2000 2
1 2
1 3
1 4
2 5
2 6
2 7
3 8
3 9
3 10
4 11
4 12
4 13
5 14
5 15
5 16
6 17
6 18
6 19
7 20
7 21
7 22
8 23
8 24
8 25
9 26
9 27
9 28
10 29
10 30
10 31
11 32
11 33
11 34
12 35
12 36
12 37
13 38
13 39
13 40
14 41
14 42
14 43
15 44
15 45
15 46
16 47
16 48
16 49
17 50
17 51
17 52
18 53
18 54
18 55
19 5...

output:

50545980022
85
1 9 10 8 75 76 74 666 667 665 1996 1994 1995 222 221 223 25 23 24 3 4 2 20 22 21 188 189 190 1712 1713 1714 571 569 570 63 62 64 7 6 5 44 46 45 401 403 402 1207 1205 1206 134 135 136 15 14 16 141 142 140 1256 1257 1258 419 420 421 47 48 49 437 439 438 1315 1313 1314 146 148 147 1322 1...

result:

ok correct!

Subtask #4:

score: 4
Accepted

Dependency #3:

100%
Accepted

Test #60:

score: 4
Accepted
time: 641ms
memory: 114984kb

input:

200000 2
71973 76326
97670 168508
171244 5932
115231 147408
128416 153589
19744 26807
67878 98255
22662 194128
198320 150303
86723 49603
10517 32984
185691 125147
174597 24994
81050 42404
165800 182920
89285 145179
128551 33017
183430 8057
41020 176174
198318 18811
152231 31881
114181 60045
29558 13...

output:

882399295740
1706
1 188460 70658 114345 125662 13738 118312 88056 86342 20469 125150 198830 34184 171733 25207 19094 188755 39714 183607 31328 125185 146149 103823 179243 66259 85349 166905 94524 128306 113506 175419 85783 172850 128380 116967 14671 121935 32772 177196 28309 182363 23520 126355 4470...

result:

ok correct!

Test #61:

score: 4
Accepted
time: 646ms
memory: 114940kb

input:

200000 2
32082 187519
5208 145093
50076 154772
187374 120564
139957 35735
23362 7323
91085 172598
85906 42406
71445 72269
152408 175847
109126 170295
57424 51948
142288 190335
46434 27012
196277 147605
116314 115538
181190 11940
23862 22122
71611 183053
142917 98634
45954 4192
110819 169037
49947 10...

output:

833023647871
1601
1 168670 74461 42679 47846 197507 193300 176275 180727 166695 92511 43467 39799 146165 23625 27565 102454 169208 199030 33416 53139 41207 160947 107708 173852 140499 24046 137147 162828 29429 166803 83672 43797 44352 155400 122620 171907 112784 162293 35944 35384 17828 155360 90578...

result:

ok correct!

Test #62:

score: 4
Accepted
time: 649ms
memory: 114928kb

input:

200000 2
78638 58642
112962 25496
85068 25026
70130 61586
173031 26076
136367 101291
127709 139920
71308 101369
136151 162399
15899 42470
188783 14739
148981 125658
63825 51000
43025 32262
1942 892
186758 34888
111721 75954
15727 114535
43402 80763
159252 40071
178432 174508
140837 145658
110251 183...

output:

859520154059
1660
1 21614 125446 25670 191534 196343 187768 140446 45970 27859 18992 121704 100825 54900 10573 79538 148400 89131 789 144926 27182 178645 5432 190456 44197 136394 68411 65945 190483 142052 99192 156697 37838 170879 66095 56339 174946 37254 46668 22149 43408 135100 124057 179674 12964...

result:

ok correct!

Test #63:

score: 4
Accepted
time: 654ms
memory: 114816kb

input:

200000 2
113130 116994
199787 127733
175019 81432
178540 179218
84082 127210
163623 155486
189624 73275
82498 8202
61848 113067
100558 173153
127108 94716
127580 54314
147631 53398
105967 1535
32421 100984
28479 170565
50049 13612
128342 24121
161245 52286
199917 196293
126521 9391
115032 50698
4507...

output:

942852419968
1789
1 54853 35470 18260 184539 4032 180649 114891 100566 43965 118876 2432 11834 85974 187170 30455 157244 114806 106938 47521 22337 185951 122055 148648 67473 23492 26493 71377 92332 192004 29807 151083 46667 152250 101756 54419 150005 90820 174399 87993 28631 87133 41631 75884 154481...

result:

ok correct!

Test #64:

score: 4
Accepted
time: 666ms
memory: 115120kb

input:

200000 2
77664 54637
84144 154928
72506 50449
160113 77853
194182 38791
107483 80245
9315 30663
148025 33975
102823 42879
52529 135121
22346 28336
97279 42789
117070 88657
79123 108461
132766 124070
106264 167067
191149 170038
150680 124017
122526 80240
22015 134260
180496 175307
74449 114090
104518...

output:

1171517212692
2265
1 102983 154271 97112 170812 10816 9666 71235 136548 1981 158535 115214 34582 17610 30341 74635 139749 32416 54904 164065 21027 131128 47965 141731 26732 110282 162611 194069 8644 27065 94646 62396 12865 8199 61499 191102 160142 31048 149413 52987 199682 80077 31632 31643 165244 5...

result:

ok correct!

Test #65:

score: 4
Accepted
time: 687ms
memory: 114728kb

input:

200000 2
28934 176056
136164 196254
31381 23123
25526 108297
57361 64966
190533 45227
74484 164959
28842 2327
81570 179755
188864 38342
104303 102044
136042 74199
171111 80778
111330 158089
52128 170798
101490 145339
120609 82326
173031 112314
73010 112478
119847 138176
122774 4868
42346 105059
3350...

output:

2326744528710
4529
1 114380 167604 133398 5416 171795 102953 80499 134654 50573 111518 93720 38805 86520 63808 85082 186882 93951 87227 125125 98497 20045 83457 77886 59467 94418 197201 120314 181605 76794 48819 37714 180991 48145 127620 162364 116899 165395 22723 66442 105664 43079 101407 167324 44...

result:

ok correct!

Test #66:

score: 4
Accepted
time: 431ms
memory: 115520kb

input:

200000 2
56021 51529
68684 59222
42913 113684
79211 108152
31389 101993
34308 149833
158947 72984
107009 139522
86949 11829
111788 59214
112750 12966
27645 157963
59289 59222
139737 47437
145601 58355
32220 146798
111541 185862
25607 45580
152343 179102
72458 111092
176999 19531
66379 119683
76547 1...

output:

767459126849
1505
1 123137 81252 27921 69616 78391 183821 29679 177828 114969 9328 22977 163739 83620 4487 62528 196629 188401 10260 49535 7115 99185 40243 160579 147829 158581 129974 17927 75465 164216 199963 187861 158376 117443 89005 130386 110511 190184 26284 130324 81892 102299 3298 24843 12218...

result:

ok correct!

Test #67:

score: 4
Accepted
time: 692ms
memory: 114916kb

input:

200000 2
104390 122869
25883 142866
160515 43820
128440 13022
8318 136414
157868 188440
156836 187687
167016 9347
39806 182142
179923 72411
45877 114238
114548 82833
40280 113331
69170 31456
118069 101689
177443 61482
19872 186357
168183 107559
61588 170900
16642 45648
747 57401
94126 173098
136686 ...

output:

3675388620625
7158
1 156746 25359 182551 171456 6217 58698 76669 46957 81229 104140 107564 43096 196087 49741 18405 71606 17284 46140 169469 68862 3806 60578 21865 49934 98544 124696 96209 186730 73717 120868 172295 148274 37265 117606 53755 167968 145692 11307 151374 3959 82355 73614 35810 173849 1...

result:

ok correct!

Test #68:

score: 4
Accepted
time: 415ms
memory: 115752kb

input:

200000 2
109985 87619
37980 22189
97113 50655
141404 55232
147996 65598
36748 174192
131854 177776
18218 47619
13160 113823
86872 169443
90387 198777
81052 158293
27515 37979
198311 51356
166249 142601
91346 8372
139757 47600
133114 143533
186906 52882
52043 134177
106749 3786
33870 108458
116250 23...

output:

992123589063
1945
1 177461 68194 157597 149879 33891 13650 94283 173999 155315 191943 2177 88983 128930 83935 85868 29637 171497 84624 38048 149357 34401 132730 169319 52698 110927 157097 10613 198350 102904 140302 141943 178279 156933 159047 124714 120543 105056 98157 112560 35504 127323 14687 1736...

result:

ok correct!

Test #69:

score: 4
Accepted
time: 679ms
memory: 115180kb

input:

200000 2
100522 147187
54889 185960
38949 138090
86106 80207
27403 199320
146820 181967
134302 13313
25408 138672
72842 34248
161006 103810
196273 40476
105432 101143
194952 131699
159995 85132
78133 40501
20116 1846
85728 109828
53166 107050
53317 170563
49857 175255
156370 158685
46487 66693
85983...

output:

3540743394022
6910
1 16382 46821 23365 146371 150697 153311 194290 168802 26336 158012 159465 103012 116421 94377 107276 105006 146400 59201 8935 174594 42636 63889 94029 62947 161170 176587 4124 199890 35236 33953 48870 8028 36632 175495 135353 89771 84748 95125 74192 181238 155630 57348 14051 1321...

result:

ok correct!

Test #70:

score: 4
Accepted
time: 422ms
memory: 115724kb

input:

200000 2
89710 128357
3426 66417
52472 91874
31627 100433
198960 160902
176265 76059
70560 72724
139051 191341
512 111102
120209 75664
15138 126122
197008 153163
179022 152817
2515 43991
27182 1020
128784 150584
143001 48543
24479 138105
188695 57568
93380 190780
71186 124797
159152 141009
21133 382...

output:

1337020465724
2654
1 13693 164771 164656 118395 145728 79029 133739 116773 134117 128711 182464 105294 20797 196406 151306 104172 131481 79713 119937 25060 1388 79596 25420 132951 9807 22015 62307 6881 184329 69092 28715 119872 161823 36046 193963 162876 152133 134496 8449 158458 79954 180290 88096 ...

result:

ok correct!

Test #71:

score: 4
Accepted
time: 311ms
memory: 126312kb

input:

200000 2
1 121764
151707 1
1 146498
120892 1
1 167954
37051 1
65946 1
142412 1
1 33774
134506 1
163786 1
1 175250
1 164690
159445 1
1 60645
1 1330
139128 1
121091 1
17510 1
89422 1
20081 1
1 172899
177661 1
1 172826
1 43543
1 177837
28825 1
1 120168
1 38254
1 8601
58920 1
147872 1
1 41335
1 164269
1...

output:

99770036814555
200000
1 121764 151707 146498 120892 167954 37051 65946 142412 33774 134506 163786 175250 164690 159445 60645 1330 139128 121091 17510 89422 20081 172899 177661 172826 43543 177837 28825 120168 38254 8601 58920 147872 41335 164269 142717 2235 77827 38923 6890 164004 189914 51287 51314...

result:

ok correct!

Test #72:

score: 4
Accepted
time: 427ms
memory: 117012kb

input:

199999 2
67072 1
92171 150753
90888 151980
49069 30219
174222 9855
195658 1
1 87942
77002 134696
1 65126
109947 3424
145914 162383
1 2757
1 112019
164258 1
66908 62514
185957 1
122946 13227
1 18985
173656 190833
1 102891
1 6832
47914 29907
184372 1
177178 1
174467 87761
132840 1
145220 137302
1 1590...

output:

99914041431818
100002
1 135761 71359 67072 195658 87942 65126 2757 112019 164258 185957 18985 102891 6832 184372 177178 132840 159078 113454 148038 16101 77008 117116 68856 128664 146086 60937 48718 118590 47520 131079 32622 44558 91651 198614 43733 70863 127993 165124 72041 195085 194067 56614 1155...

result:

ok correct!

Test #73:

score: 4
Accepted
time: 536ms
memory: 111716kb

input:

199997 2
181667 73912
70196 155617
57266 177774
146844 22851
17625 44807
140237 145179
71321 26122
119873 142655
42888 1
1 12665
2354 21037
157498 117106
154042 78181
9589 1
46002 137008
19680 124524
133338 79920
1 118916
65513 53811
163778 43702
29017 144717
98739 157944
189251 183682
182803 178046...

output:

49962213918134
50006
1 177685 2544 180804 149002 42888 12665 9589 118916 98573 70815 131340 121671 17422 7097 108910 165181 141826 176793 166101 84566 164449 48670 151440 28546 89451 160627 79042 174818 197212 175855 44478 87893 4722 67241 153469 147268 179610 31528 90140 20389 166773 193752 61741 9...

result:

ok correct!

Test #74:

score: 4
Accepted
time: 353ms
memory: 109728kb

input:

199809 2
169878 4225
23345 92377
98479 42575
149948 72420
50892 90193
47118 16414
69072 47907
48571 63127
149065 40766
143982 72205
169350 85345
154664 137516
154095 72685
95325 102444
101466 119755
32299 39632
58986 95625
177381 137516
36382 110945
69668 129015
97533 177853
32749 35220
121826 30883...

output:

713049791453
1341
1 166149 3214 13776 34605 159467 72184 131684 15137 77456 185879 3525 104905 30931 199335 72722 109248 81509 26119 100984 83258 151934 124114 26223 136053 67005 3646 89167 194608 115529 13056 102189 14182 96328 69690 103747 168053 104871 147207 164612 36463 185614 137314 105796 726...

result:

ok correct!

Test #75:

score: 4
Accepted
time: 723ms
memory: 285184kb

input:

200000 2
5189 138698
162040 22588
64703 112781
3394 136450
174354 3779
21094 6916
88534 109117
134528 32716
199107 74065
151148 26217
128242 194757
185664 167983
19773 60770
11507 105959
161807 139962
38366 176916
185209 97924
54025 141961
190880 55231
43069 120905
94677 20549
79285 158427
82389 310...

output:

200000000000000
200000
1 160015 25853 132332 99641 54513 128636 56316 58204 48834 141207 195883 117428 18073 83196 27770 159851 191594 50501 197504 148078 79302 171178 145374 174465 167859 152787 170071 128200 93211 123590 5744 40903 136953 33704 84890 77459 20538 55723 147629 195405 91378 17655 133...

result:

ok correct!

Test #76:

score: 4
Accepted
time: 894ms
memory: 204724kb

input:

200000 2
27363 14113
105695 61177
18014 22956
18808 177624
148980 14330
95219 115023
116364 74015
136966 188653
121569 4887
83271 90316
84619 130170
84529 45369
23977 192773
175001 80000
73676 20454
99853 7287
177160 58905
36849 94281
58588 29241
657 180060
2293 174820
128219 100022
88580 55357
1264...

output:

99922046309746
200000
1 173986 3898 47452 153804 123007 48631 145599 83548 18765 64540 135694 3575 21353 108000 163018 109084 99159 147779 74689 33496 173651 48295 131873 91026 6853 51540 88821 188955 167533 132935 73754 38412 198306 61130 43771 66809 129784 78271 55414 109232 63609 65236 108676 624...

result:

ok correct!

Test #77:

score: 4
Accepted
time: 676ms
memory: 167152kb

input:

200000 2
100468 181493
53969 172322
75135 130909
139964 194504
19021 125659
37607 9557
72510 180054
167286 130071
45448 136281
73858 61335
140036 142670
159885 42363
154039 91451
37090 97684
45858 15964
98746 33430
68396 72322
29978 140827
33566 154533
157183 98893
184791 130026
39154 3812
132886 59...

output:

100057925839612
200000
1 4288 24196 51235 104946 68939 173538 182996 142523 46064 168003 178567 103046 79260 137544 193015 117911 138195 58000 101558 153606 176303 174754 6670 126340 12325 18378 111857 37605 148688 91927 26071 125622 30356 115584 163828 100557 179828 94540 150624 118214 75548 114197...

result:

ok correct!

Test #78:

score: 4
Accepted
time: 865ms
memory: 162468kb

input:

200000 2
171220 164313
198029 73747
26096 85012
110214 89139
172790 175093
171731 30080
69767 9015
141703 177975
79195 71430
44626 160824
146861 163709
156800 76389
19445 181416
113267 89896
124839 30054
80809 151537
99873 187186
100638 166286
44321 120253
183612 28877
15242 180944
89632 190302
6708...

output:

99911380218441
200000
1 49359 165115 74567 110902 50086 90003 61841 179907 93501 158123 18507 174986 17756 153696 128199 80988 114565 198396 22083 131204 27651 188226 35685 72521 66728 92098 135609 95306 75124 144381 66938 127386 7997 112758 134995 152766 95415 174294 26783 132532 99483 103242 89332...

result:

ok correct!

Test #79:

score: 4
Accepted
time: 828ms
memory: 141784kb

input:

200000 2
8314 177328
146834 168561
24273 99494
153115 63830
166298 9934
167286 101744
109715 98447
784 143770
22271 37823
83151 28850
174199 89913
24577 115223
149285 39182
5074 9380
197079 150501
121534 133095
191134 195404
60411 87734
182665 135214
187189 119252
166358 54195
156812 155428
18144 19...

output:

80866474815147
150002
1 81709 27495 161651 51720 144385 777 72674 132921 127681 61334 170860 159326 71316 139005 118114 112873 15221 47510 29559 92531 145893 76612 71572 73238 18113 23874 134330 55096 111676 70015 806 113662 44707 8384 96493 160968 140462 29862 192411 173965 140921 120551 140689 176...

result:

ok correct!

Test #80:

score: 4
Accepted
time: 717ms
memory: 130896kb

input:

200000 2
169179 38103
45411 72139
139020 184462
125323 167101
163401 46625
97240 145227
77416 13783
135642 68825
116351 57737
32614 100924
171164 135235
123336 159074
118178 33394
108090 135019
128087 172240
108313 170956
27543 69102
7341 141209
190919 35931
38512 119039
191316 21753
70270 112143
19...

output:

75697889479414
140003
1 7593 123209 199714 147004 26824 20568 144457 11617 22999 129351 85957 83291 183777 115533 62588 44152 192129 119533 105918 27845 91404 199835 157136 163990 100209 151007 8348 191421 66318 172397 162642 133696 153526 92994 35462 75896 122045 112534 110727 93694 14171 35342 862...

result:

ok correct!

Test #81:

score: 4
Accepted
time: 692ms
memory: 119476kb

input:

200000 2
1 2
1 3
2 4
2 5
3 6
3 7
4 8
4 9
5 10
5 11
6 12
6 13
7 14
7 15
8 16
8 17
9 18
9 19
10 20
10 21
11 22
11 23
12 24
12 25
13 26
13 27
14 28
14 29
15 30
15 31
16 32
16 33
17 34
17 35
18 36
18 37
19 38
19 39
20 40
20 41
21 42
21 43
22 44
22 45
23 46
23 47
24 48
24 49
25 50
25 51
26 52
26 53
27 54...

output:

208672979041
307
1 7 6 25 24 96 97 391 390 1560 1561 6247 6246 24984 24985 99943 99942 199885 199884 49971 49970 12492 12493 3123 3122 780 781 195 194 48 49 12 13 3 2 8 9 38 39 158 159 636 637 2548 2549 10197 10196 40787 40786 163144 163145 81572 81573 20393 20392 5098 5099 1274 1275 318 319 79 78 1...

result:

ok correct!

Test #82:

score: 4
Accepted
time: 508ms
memory: 108376kb

input:

200000 2
1 2
1 3
1 4
2 5
2 6
2 7
3 8
3 9
3 10
4 11
4 12
4 13
5 14
5 15
5 16
6 17
6 18
6 19
7 20
7 21
7 22
8 23
8 24
8 25
9 26
9 27
9 28
10 29
10 30
10 31
11 32
11 33
11 34
12 35
12 36
12 37
13 38
13 39
13 40
14 41
14 42
14 43
15 44
15 45
15 46
16 47
16 48
16 49
17 50
17 51
17 52
18 53
18 54
18 55
19...

output:

135510774019
199
1 5 6 7 59 60 61 551 552 553 4977 4978 4976 44783 44785 44784 134353 134351 134352 14928 14927 14929 1659 1658 1660 184 182 183 20 21 22 2 4 3 26 27 28 254 256 255 2295 2296 2294 20649 20650 20648 185828 185829 185830 61943 61944 61945 6883 6881 6882 765 764 766 85 83 84 9 10 8 74 7...

result:

ok correct!

Subtask #5:

score: 0
Wrong Answer

Test #83:

score: 4
Accepted
time: 7ms
memory: 43972kb

input:

2000 3
1359 90
1703 163
158 188
360 1501
195 664
1414 215
1546 1756
536 1096
1726 1223
1150 104
1757 703
1982 282
1023 998
1180 419
576 1759
1496 1993
44 670
1703 952
855 849
1998 1399
1280 980
1533 1090
1270 678
1680 387
469 1734
1799 263
473 588
303 226
5 295
1489 1471
1094 1667
1912 210
1368 1360...

output:

1008611451196
2000
1 379 1954 1539 531 605 961 1091 1613 1300 540 377 1565 1823 1237 454 1101 99 864 359 1866 1840 1369 1617 562 867 1831 243 710 1040 901 1256 709 88 916 1341 1158 1526 1238 1291 129 745 260 1967 773 1919 816 523 674 1788 832 890 1626 297 452 1961 1903 1349 1808 1428 1337 739 560 16...

result:

ok correct!

Test #84:

score: 4
Accepted
time: 13ms
memory: 43924kb

input:

2000 3
1727 567
1783 1850
205 985
323 1094
1153 821
1756 117
377 1928
1026 1303
1343 1814
268 745
242 948
1140 1218
7 1675
101 1798
1403 1752
1184 671
87 248
1953 30
1580 1441
507 1438
525 419
901 421
1585 1405
1575 883
1952 1930
1988 1325
615 722
994 1202
178 474
1978 1500
899 481
216 409
999 1817
...

output:

1012330476243
2000
1 369 1789 598 488 419 422 525 269 202 1079 694 1379 1454 1724 1545 88 246 1123 701 1522 1158 1696 1364 1918 131 1589 1832 872 1057 1532 345 1725 67 761 1634 1174 719 1807 650 693 61 718 554 841 234 1935 175 220 105 917 1784 997 1315 1530 92 257 802 1071 1369 1257 1046 1275 993 31...

result:

ok correct!

Test #85:

score: 0
Wrong Answer
time: 14ms
memory: 43832kb

input:

2000 3
1213 130
101 508
72 1199
1550 1096
1099 861
1515 627
1299 1672
1338 105
1444 1019
15 1560
1949 971
52 1312
30 529
186 1687
1917 484
1971 349
537 1223
1955 1377
300 1060
1786 1811
1960 90
1959 1353
1831 1548
303 511
1073 1197
863 1527
1379 994
31 9
1247 1707
1395 1532
29 1544
119 296
1919 1554...

output:

803960409885
1502
1 1365 1487 1721 810 1986 1821 668 513 1002 830 1255 1557 751 574 1802 1658 1491 60 1261 640 1010 374 1292 1450 1710 1896 942 718 1246 706 295 1377 1955 729 954 242 1809 93 1610 381 435 1127 863 384 1356 1067 181 1503 1169 1153 1997 1241 563 1475 1303 1310 1208 388 1069 1483 1181 8...

result:

wrong answer your profit is 803960409885 but jury's plan is 1001405462082, your plan is not optimal!

Subtask #6:

score: 0
Skipped

Dependency #5:

0%