QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#179612#2812. Pathsluanmenglei100 ✓169ms23352kbC++172.5kb2023-09-14 23:00:252023-09-14 23:00:25

Judging History

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

  • [2023-09-14 23:00:25]
  • 评测
  • 测评结果:100
  • 用时:169ms
  • 内存:23352kb
  • [2023-09-14 23:00:25]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

using i64 = long long;
using Node = pair<i64, int>;
const int N = 1e5 + 10;
vector<pair<int, int>> G[N];
int n, k, top[N], from[N];
i64 sum[N], val[N], res, ans[N];
bool v[N];
Node son[N], seson[N], oson[N];
set<Node> s, os;

Node reduce(const Node &x, i64 k) { return { x.first - k, x.second }; }

void dfs1(int x, int fa) {
	if (G[x].size() == 1) son[x] = { sum[x], x };
	for (auto [y, z] : G[x]) if (y != fa) {
		sum[y] = sum[x] + z;
		dfs1(y, x);
		if (son[x] < son[y]) from[x] = y, seson[x] = son[x], son[x] = son[y];		
		else if (seson[x] < son[y]) seson[x] = son[y];
	}
}

void dfs2(int x, int fa) {
	for (auto [y, z] : G[x]) if (y != fa) {
		top[son[y].second] = x;
		if (from[x] == y) oson[y] = max(oson[x], reduce(seson[x], sum[x]));
		else oson[y] = max(oson[x], reduce(son[x], sum[x]));
		oson[y].first += z;
		dfs2(y, x);
	}
	if (son[x].second) top[son[x].second] = fa;
} 

void update(int x, i64 d) {
	if (v[x]) {
		auto it = s.find({ val[x], x });
		s.erase(it), res -= val[x];
		val[x] += d;
		if (!os.empty() && prev(os.end()) -> first > val[x]) {
			it = prev(os.end());
			s.insert(*it), res += it -> first, v[it -> second] = true;
			os.erase(it);
			os.emplace(val[x], x), v[x] = false;
		} else {
			s.emplace(val[x], x), res += val[x];
		}
	} else {
		auto it = os.find({ val[x], x });
		os.erase(it);
		val[x] += d;
		if ((int) s.size() < k || s.begin()->first < val[x]) {
			it = s.begin();
			res -= it -> first, v[it -> second] = false, os.insert(*it);
			s.erase(it);
			s.emplace(val[x], x), res += val[x], v[x] = true;
		} else {
			os.emplace(val[x], x);
		}
	}
}

void dfs3(int x, int fa) {
	ans[x] = res;
	for (auto [y, z] : G[x]) if (y != fa) {
		update(son[y].second, -z);
		update(oson[y].second, z);
		dfs3(y, x);
		update(son[y].second, z);
		update(oson[y].second, -z);
	}
}

int main() {
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n >> k;
	for (int i = 1, x, y, z; i < n; i ++) {
		cin >> x >> y >> z;
		G[x].emplace_back(y, z);
		G[y].emplace_back(x, z);
	}
	dfs1(1, 0), dfs2(1, 0);
	for (int i = 1; i <= n; i ++) if (G[i].size() == 1) {
		val[i] = sum[i] - sum[top[i]];
		s.emplace(val[i], i);
		v[i] = true, res += val[i];
		if ((int) s.size() > k) {
			auto it = s.begin();
			v[it -> second] = false, res -= it -> first;
			os.insert(*it), s.erase(it);
		}
	}
	dfs3(1, 0);
	for (int i = 1; i <= n; i ++) cout << ans[i] << "\n";
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 8
Accepted

Test #1:

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

input:

18 6
10 7 97855404
4 18 271509075
10 5 640280256
10 6 2904681
16 9 488858162
16 3 44121154
5 15 64322969
10 17 706372605
1 4 42055592
16 1 292596570
3 12 864954720
16 14 49594213
17 11 512414035
3 13 4292601
17 16 259237202
16 2 43275568
15 8 293012354

output:

4577590098
4620865666
4577590098
4577590098
4577590098
4580494779
4627184311
4627184311
4627184311
4577590098
4627184311
4627184311
4581882699
4627184311
4577590098
4577590098
4577590098
4627184311

result:

ok 18 lines

Test #2:

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

input:

18 4
8 10 328716094
11 7 385474656
14 9 462809825
4 1 224397756
13 15 174547767
12 8 248797898
16 18 325511345
17 2 42739490
11 14 19051747
11 4 358214121
1 13 66103380
11 17 217728114
11 5 233371890
11 16 135184612
11 3 303701979
11 12 125285765
12 6 291578508

output:

2613443819
2729087914
2772322289
2468620310
2701992200
2760198818
2854094966
2525378872
2854094966
2854094966
2468620310
2468620310
2679547199
2468620310
2854094966
2528583621
2686348424
2854094966

result:

ok 18 lines

Subtask #2:

score: 11
Accepted

Test #3:

score: 11
Accepted
time: 0ms
memory: 5964kb

input:

200 20
51 199 199727220
68 117 478346264
144 176 781278350
71 115 814270800
187 94 49184940
47 59 295564074
86 33 653657775
69 27 800777550
125 105 476166560
150 163 197350992
162 84 155379511
24 122 20524383
72 62 84029232
59 15 1678950
145 102 304107568
101 6 550017237
11 38 22064016
147 73 692427...

output:

28909157390
28445340920
28764957709
28445340920
28620150349
28445340920
28483160301
28508687588
28514357589
28445340920
28731486793
28445340920
29287699109
28666527346
28765701352
29045907515
29026699776
28559491242
28825672768
28839962799
28698906767
28639170204
28680419632
28445340920
29019800067
...

result:

ok 200 lines

Test #4:

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

input:

200 16
11 149 180205947
165 64 586913960
113 76 467916822
59 61 130045728
6 169 186647026
32 185 49236699
78 72 26227397
154 106 339569005
191 30 143892700
5 124 976506870
71 88 70016787
68 137 9578212
72 35 213870072
43 44 16276531
21 49 154652536
117 199 114949570
169 189 273707122
102 40 14574621...

output:

37493615354
38173325965
37524428689
37493615354
37493615354
37493615354
37493615354
37838030390
37651041962
37674740157
37493615354
37493615354
37668938782
37493615354
37493615354
38173325965
37584134456
37599463081
37659511036
37493615354
37493615354
37935853565
37493615354
37493615354
37493615354
...

result:

ok 200 lines

Test #5:

score: 0
Accepted
time: 0ms
memory: 5864kb

input:

200 20
142 157 19872979
175 85 187270476
175 10 281779860
175 168 402426735
175 71 344044980
175 20 36288220
175 95 27008968
175 193 56132802
169 80 77006450
37 5 14713704
175 12 13731570
175 50 164959830
175 180 602580088
70 30 773116674
23 11 94926912
84 181 41867370
175 7 427908
175 25 621765820
...

output:

21639404766
22120843161
22050043502
22312278216
21841543610
22396072846
21639832674
21857197932
21823659427
21829772604
21953004801
21653136336
21980854516
22396072846
21965916844
22396072846
21764141904
21876878372
21641356872
21675692986
22025958170
22396072846
21858077889
22396072846
21639404766
...

result:

ok 200 lines

Test #6:

score: 0
Accepted
time: 0ms
memory: 5980kb

input:

200 12
7 91 53257128
34 145 374359970
146 75 19680111
57 27 669150834
39 132 359818388
64 14 304902690
15 65 104664240
143 69 343526365
109 166 296196864
157 155 134785040
192 107 332572350
105 63 477497836
131 13 282685368
45 149 192149470
13 48 13454280
74 165 600896128
156 70 197079575
190 74 229...

output:

49622073155
49622073155
49622073155
49622073155
49622073155
49622073155
49622073155
49622073155
50048380475
50186647340
50186647340
50124261093
49957823019
49622073155
49622073155
49622073155
49622073155
49622073155
49903616923
49622073155
49622073155
50111458872
49753573079
49622073155
49622073155
...

result:

ok 200 lines

Test #7:

score: 0
Accepted
time: 0ms
memory: 5940kb

input:

200 18
23 85 60
93 52 900000530
46 190 654
23 13 920
104 35 792
78 158 28
2 72 900000385
140 18 240
160 42 450
188 177 320
133 25 589
45 128 630
39 130 380
23 95 510
28 47 446
151 36 16
13 8 544
74 199 695
101 135 394
44 99 504
198 97 874
26 58 991
86 113 616
44 88 435
136 9 128
145 196 438
179 118 ...

output:

13500069076
13500069076
13500069076
13500070188
13500069380
13500069616
13500071117
13500069620
13500069078
13500071011
13500069076
13500070350
13500069076
13500069076
13500069076
13500069477
13500070190
13500069076
13500069262
13500069295
13500071117
13500069643
13500069076
13500069076
13500069665
...

result:

ok 200 lines

Subtask #3:

score: 17
Accepted

Dependency #2:

100%
Accepted

Test #8:

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

input:

1000 99
956 677 74601142
701 213 408780874
427 557 103134603
679 209 402565472
13 45 98479730
582 472 706873970
464 965 62258659
706 56 88402050
495 994 31070928
995 453 777980954
923 168 669156600
883 910 664396960
233 672 698576495
324 464 244647547
444 931 71874570
293 28 41242172
257 287 2460266...

output:

153716811551
152862136146
152862136146
152901806036
152862136146
152862136146
152951254414
152862136146
153716811551
152862136146
152862136146
153117953994
152862136146
152862136146
152927681472
153022343256
152881597406
153096052392
153220444561
153425340081
153298893653
152871380158
152998636146
1...

result:

ok 1000 lines

Test #9:

score: 0
Accepted
time: 0ms
memory: 6192kb

input:

1000 45
471 635 129476222
257 749 212006687
843 719 172560096
707 5 268570691
687 236 74269344
850 999 270527397
655 419 352545626
723 187 101293588
177 590 212543136
566 865 715214311
611 826 9054906
561 990 307063086
724 587 2205330
495 870 305706990
814 599 287789328
127 642 450898275
351 623 375...

output:

211813973991
211557571020
211557571020
211614619706
211557571020
211557571020
211680568548
211754388445
211557571020
211557571020
211557571020
211557571020
211732183749
211557571020
211557571020
212095903385
211557571020
211557571020
211702833365
211557571020
211669021948
211557571020
211918790729
2...

result:

ok 1000 lines

Test #10:

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

input:

1000 36
201 765 155867304
287 778 179592528
242 520 273137241
488 163 179747308
862 867 16002898
531 477 653539740
614 375 580789000
491 260 125804168
11 42 262418244
355 286 363902346
290 693 352519328
843 318 296463723
696 746 100295172
624 625 170100208
784 507 391191680
958 475 524920473
449 827...

output:

227910463187
227910463187
227910463187
228166943225
227910463187
227977301347
227910463187
227910463187
229003870672
228907982182
227910463187
229659406565
228838062195
227910463187
229173362457
227910463187
227910463187
227910463187
228423163057
228170278325
227910463187
228638517862
228422482855
2...

result:

ok 1000 lines

Test #11:

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

input:

1000 92
615 196 430655097
615 175 290240
418 504 212031568
749 918 503776944
615 579 180830022
615 746 29041032
615 24 39476060
615 903 11437191
615 57 840648402
694 305 317270967
615 475 450887250
927 38 112960482
615 115 270416622
615 792 353672108
615 224 56365308
464 277 20128494
177 850 2861556...

output:

112480419799
112445607035
112525052318
112239525148
112292168292
112352494139
112315964326
112629004033
112427393983
112618296496
112330181438
112741426165
112577420098
112865848152
112738915391
112292102505
112643559777
112635655090
112360830298
112528610148
112246428800
112340064807
112256744448
1...

result:

ok 1000 lines

Test #12:

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

input:

1000 72
632 310 900000455
148 561 900000588
358 357 900000060
705 940 10
934 769 973
29 444 970
619 178 900000203
493 326 840
593 914 900000367
435 317 219
595 786 900000528
486 730 244
436 183 564
826 885 876
757 466 475
911 649 834
660 430 836
87 808 900000600
2 20 900000540
45 754 672
985 839 900...

output:

395100222769
395100222769
395100222769
396000222985
395100228159
395100224449
395100222769
395100234716
395100222769
395100222769
395100222769
395100222769
395100230156
395100222769
395100228444
396000222985
395100229545
395100223125
395100227043
395100222769
395100222769
395100231049
395100226557
3...

result:

ok 1000 lines

Subtask #4:

score: 20
Accepted

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Dependency #3:

100%
Accepted

Test #13:

score: 20
Accepted
time: 2ms
memory: 6072kb

input:

2000 620
1777 1062 28448637
1124 103 47479640
1481 1105 126362082
489 771 160831146
1180 765 423184567
1009 86 236457245
11 1752 164085480
1991 37 297671050
335 1557 3116718
957 172 327227870
1221 760 893356800
635 305 111056112
953 1518 279687937
1418 1925 220081782
1443 27 132109832
764 184 790035...

output:

490371953549
490522382229
490612781845
490586897119
490587204182
490612781845
490612781845
490371953549
490372593629
490612781845
490371953549
490371953549
490502088919
490526679869
490371953549
490371953549
490612781845
490612781845
490371953549
490521477996
490441471286
490548826414
490371953549
4...

result:

ok 2000 lines

Test #14:

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

input:

2000 124
1888 1469 300867445
564 1372 46516860
1967 1960 405353880
1739 645 290797623
143 857 893478724
1083 1803 439148980
1209 1316 496093356
1889 1559 59113080
424 1270 127922376
1301 278 850079900
1330 207 94551816
477 229 493700309
814 250 708463020
14 1516 233518290
1046 247 575333285
1011 133...

output:

400233132980
400395978925
400233132980
400233132980
400233132980
400565763902
400233132980
400233132980
400529124292
400623527460
400233132980
400241733362
400233132980
400233132980
400233132980
400233132980
400233132980
400500733616
400233132980
400233132980
400233132980
400233132980
400233132980
4...

result:

ok 2000 lines

Test #15:

score: 0
Accepted
time: 0ms
memory: 6096kb

input:

2000 27
840 282 18523947
448 158 74739854
1808 1309 261178080
1382 1245 6355752
266 40 58518226
368 101 397062956
91 752 348909056
1559 59 267206725
1633 737 176201212
1662 1579 105459312
1754 425 116911795
1405 1055 218580180
438 403 3296487
1669 1933 513146034
1374 1207 30257703
1614 1394 47655923...

output:

395729318590
392206488886
392583593335
393654396219
392206488886
392206488886
394110186103
392437750482
394192936279
394582739027
392206488886
393255701518
392206488886
392206488886
393466074558
392206488886
392206488886
392206488886
392206488886
392206488886
392206488886
392206488886
392206488886
3...

result:

ok 2000 lines

Test #16:

score: 0
Accepted
time: 4ms
memory: 6132kb

input:

2000 485
560 1927 142035085
411 784 447360732
411 1008 133930341
411 1714 85681026
1545 1445 343891064
1494 1089 149203560
981 1049 161702190
411 781 121245420
411 1704 130101569
411 794 153894312
803 662 48367929
411 556 189123984
411 15 87311000
411 464 352464090
1422 1743 362380665
491 1026 35188...

output:

413774583850
414016821886
413772395270
414016821886
414016821886
413848287190
414016821886
413578621630
413848138510
414016821886
413578621630
413963803606
413735199374
413604176401
413578621630
413866749030
414016821886
413601862822
413973911476
413865233646
413925733421
413578621630
413578621630
4...

result:

ok 2000 lines

Test #17:

score: 0
Accepted
time: 0ms
memory: 6196kb

input:

2000 298
109 1130 900000290
911 246 900000600
537 1967 561
1548 1408 995
349 1524 410
1405 264 140
1477 1782 696
1507 931 900000884
249 655 925
410 341 373
28 810 448
1476 1018 841
1079 726 245
985 1245 900000313
956 1108 946
366 1389 459
1399 1327 595
102 1880 900000160
1395 20 943
1957 1243 248
12...

output:

145800937450
145800937450
145800937450
145800937450
145800937778
145800937450
145800937483
145800937987
145800937450
145800937450
145800937450
145800938254
145800938254
145800937450
145800938254
145800938254
145800937510
145800938254
145800937703
145800937450
145800937816
145800938254
145800937450
1...

result:

ok 2000 lines

Test #18:

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

input:

1500 165
864 419 36267316
1284 1236 203740300
882 405 295857198
449 1043 183252083
1324 534 194383840
1100 1448 121402944
591 848 100468720
1439 495 27966684
898 1443 9930356
324 1399 5519950
1399 124 181050744
1256 647 387971213
1268 1365 140503110
1500 377 107487648
271 1442 42883146
768 110 23357...

output:

253553304462
253752546598
253370640342
253880145536
253383143880
253880145536
253871290767
253608079324
253880145536
253463629709
253279085846
253724978406
253276978062
253276978062
253276978062
253643175448
253448814782
253880145536
253276978062
253496082636
253289794625
253311559408
253276978062
2...

result:

ok 1500 lines

Test #19:

score: 0
Accepted
time: 0ms
memory: 6076kb

input:

2000 782
1420 88 205969484
89 1817 28430460
224 1327 233341292
361 1315 399513620
1432 1619 959905584
1515 1892 19504161
966 1753 410139750
1200 1399 791034916
769 1250 352083648
517 1393 205662072
1548 624 356122890
861 678 529467921
1940 828 267942640
547 1054 489419008
1422 1759 110357702
1285 14...

output:

537392232036
537281840739
537351222637
537298960541
537281840739
537281840739
537392232036
537281840739
537392232036
537392232036
537281840739
537392232036
537369818307
537281840739
537281840739
537392232036
537281840739
537312810756
537392232036
537281840739
537392232036
537281840739
537281840739
5...

result:

ok 2000 lines

Subtask #5:

score: 12
Accepted

Test #20:

score: 12
Accepted
time: 167ms
memory: 20644kb

input:

100000 1
24236 18313 152966972
17123 28623 795162800
9097 27971 321468928
14631 440 299415678
23899 27577 137649785
9300 1919 23849091
8903 5854 96235896
6029 15936 361112488
31091 19860 292124196
10503 12089 171061751
12083 993 888404596
7177 11284 439107788
10520 26377 76773672
1314 30740 93365142...

output:

10431002433
10332196443
9980542002
10444814169
11298877312
9836184890
8514716270
9022314166
8995844658
8941775491
9247596926
7938411675
9516776838
9167147349
8751702461
9002276929
8718668585
8319506542
10287856850
9323923626
9486626886
9531356826
10483161194
8820213542
9737569125
8522567359
92866201...

result:

ok 100000 lines

Test #21:

score: 0
Accepted
time: 155ms
memory: 23104kb

input:

100000 1
29781 28300 116885972
28215 21050 495428671
24845 30774 117769995
7940 9297 44661562
192 15872 75501529
11525 18876 702239498
10219 5284 318144800
6640 6846 689193156
6163 25995 45977546
32267 6172 940603818
13234 20166 385892171
28859 7939 27370985
27680 2966 11477910
5557 16984 134749560
...

output:

4612798439849
4348499547302
4435200114732
2909055998102
3437786608167
4051898751834
2440698596150
4272494922285
4129393347129
2444998194986
4152520672021
2524820556234
3581808213952
4769716906828
3944255735857
3588822108817
3252828703830
2894610528248
3136428581212
2428937040342
3512714402198
452575...

result:

ok 100000 lines

Test #22:

score: 0
Accepted
time: 102ms
memory: 17604kb

input:

100000 1
7581 16870 260600613
10373 27836 7761492
18408 29917 343390036
12335 27866 184794484
2613 27520 110155596
601 25120 23635101
9184 28941 384468084
10076 29044 8433726
2323 15774 10613835
337 17353 15814575
26018 30873 417491730
30883 15052 98859840
16769 31377 29004184
3068 4048 47096275
112...

output:

85053520357
74879630403
73274717983
82792040689
105145665747
74952751975
91198094163
89534747222
109805415184
88564613267
73052769384
76672315555
76041131142
81198069965
70317568596
94298956726
85092907709
75046219072
93615000441
84099248937
96273663777
118764800975
86233414672
76758532825
811759520...

result:

ok 100000 lines

Test #23:

score: 0
Accepted
time: 159ms
memory: 20692kb

input:

100000 1
15962 30184 33572875
14092 7310 695363592
31412 19439 185378336
8525 19149 22724968
14092 32340 102075148
14092 28731 510858956
14092 8211 401261480
24300 16609 864900918
5357 30793 352929729
14092 31219 153424908
14092 1221 868124160
15877 12728 87132780
14143 9035 508805976
14092 9151 427...

output:

6215476443
5610933397
7033466039
6126257188
5517592589
5540554582
6658832805
5500587980
5605249897
5946869301
6084987795
5686372350
6297124318
5399630888
5738294604
5931369625
6036135056
5845031852
5440853659
5615802208
5702305142
5382715886
5739562405
6094387457
5623648060
6163314046
5616495856
597...

result:

ok 100000 lines

Test #24:

score: 0
Accepted
time: 168ms
memory: 21612kb

input:

100000 1
7064 13170 25235625
19321 17015 9895263
17678 6593 831564438
3130 28342 22806396
28258 26205 331866248
9275 10723 547045245
17643 21049 351258507
10016 8545 778505796
11610 6718 1399112
16693 18637 52275000
8714 5749 272969676
31840 32699 132259836
23138 24873 76483698
24487 10899 509324811...

output:

1492869801954
2012423336495
2271743029323
2314728752291
2555707939456
2360106222525
2379527361555
1827839000256
1730990030818
2064522321395
2252780773506
2498541154380
2377520812976
1368309504561
2277783467158
1753176393474
1712454038793
1802066486859
2710788989986
2438223180855
1467453704810
156477...

result:

ok 100000 lines

Test #25:

score: 0
Accepted
time: 151ms
memory: 20640kb

input:

100000 1
32343 28508 2247570
32343 28173 33898830
32343 31029 392893704
32343 7112 3442329
32343 13001 212438650
32343 12529 30820800
32343 331 125408250
32343 3206 264819880
32343 3065 46704879
32343 6825 18557373
24001 6388 87903689
32343 17275 243375560
32343 10837 313540128
32343 24771 877372244...

output:

3908203403
4108400690
4734469584
3974619493
3998925855
4120665382
3970785949
4069448766
4657077764
4376980999
4458731171
4252794974
4106763406
4034371816
3898335496
4243171746
3980191720
3890566952
4057807112
4034927884
3998733487
4304543229
4009536406
4001895302
4391505851
4017459812
4308466690
406...

result:

ok 100000 lines

Subtask #6:

score: 32
Accepted

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Dependency #3:

100%
Accepted

Dependency #4:

100%
Accepted

Dependency #5:

100%
Accepted

Test #26:

score: 32
Accepted
time: 169ms
memory: 20648kb

input:

100000 30011
22531 27764 584935208
10572 7541 85749426
27260 26836 2061996
14816 6067 339826707
24219 871 473146230
11188 3658 694815792
19883 5486 52955845
22539 23256 507109436
16010 26336 158783270
24089 20764 221088204
13522 26358 14271510
15759 11423 23679900
17149 21384 22231818
20346 2588 112...

output:

24585501173099
24585501173099
24585577935091
24585501173099
24585565139659
24585501173099
24585547188699
24585663954565
24585501173099
24585501173099
24585501173099
24585501173099
24585501173099
24585501173099
24585501173099
24585501173099
24585712468431
24585528003183
24585693861070
24585501173099
...

result:

ok 100000 lines

Test #27:

score: 0
Accepted
time: 167ms
memory: 20580kb

input:

100000 19232
14117 12849 274302976
14117 9446 317698992
14117 17662 50424363
14117 26446 893846950
32528 18234 136879600
28655 6064 176754682
14117 22947 666595500
921 12396 99364050
14117 29488 221713983
14117 16010 35298000
14117 10697 687104
15029 16292 45143645
14117 27712 452732
14117 23963 445...

output:

20061231913946
20061748764973
20061748764973
20061608488256
20061231913946
20061501204873
20061231913946
20061252239614
20061305916768
20061748764973
20061231913946
20061385222184
20061231913946
20061231913946
20061278969213
20061231913946
20061231913946
20061522322625
20061574525450
20061231913946
...

result:

ok 100000 lines

Test #28:

score: 0
Accepted
time: 130ms
memory: 23008kb

input:

100000 17328
25508 21788 414999682
11493 28400 48535390
6517 11490 336006720
10075 11376 38629348
985 28100 35609940
5260 26104 19654656
26109 7742 220404930
28667 21431 60773440
39 27999 535852896
16103 26514 5321340
26253 22483 72738666
28287 11477 476271300
27076 31179 118946930
29202 13585 20075...

output:

24391041197836
24391041197836
24391041197836
24391041197836
24391041197836
24391041197836
24391041197836
24391041197836
24391041197836
24391041197836
24391041197836
24391041197836
24391041197836
24391041197836
24391041197836
24391041197836
24391041197836
24391041197836
24391041197836
24391041197836
...

result:

ok 100000 lines

Test #29:

score: 0
Accepted
time: 163ms
memory: 22896kb

input:

100000 1877
30512 27305 346192704
7436 19668 196763280
31405 4834 575820206
15795 20203 14187250
11747 30666 639611735
3574 15668 227505870
23615 1836 5656420
6077 30083 20319437
6124 15718 265412104
24891 32559 570689184
27424 24162 155721860
11017 12461 7740696
30671 13024 37681008
5013 23245 3032...

output:

8581014127135
8581014127135
8582033440144
8581263760897
8581199006524
8581014127135
8581014127135
8581532794172
8581014127135
8581014127135
8581288912065
8581014127135
8581014127135
8581014127135
8581014127135
8581014127135
8581350375774
8581086143654
8581014127135
8581014127135
8581036521967
858101...

result:

ok 100000 lines

Test #30:

score: 0
Accepted
time: 152ms
memory: 23352kb

input:

100000 11232
22366 14221 281214648
29278 8641 410224266
27419 13449 288682446
22447 22067 284754352
16796 26241 212041620
27405 21677 15394104
25129 5370 979381385
31608 17797 20187570
24813 24006 52809335
30798 2399 282260575
30466 30716 47876814
24188 9800 14112000
10350 5700 123264875
6616 15847 ...

output:

17995322330728
17995322330728
17995512733703
17995322330728
17995322330728
17995322330728
17995322330728
17995322330728
17995736449258
17995322330728
17995322330728
17995322330728
17995322330728
17995322330728
17995322330728
17995322330728
17995322330728
17995322330728
17995322330728
17995322330728
...

result:

ok 100000 lines

Test #31:

score: 0
Accepted
time: 94ms
memory: 17564kb

input:

100000 104
7732 27727 192990020
32123 15855 366321333
1336 14415 191319534
7851 717 276989200
22068 5694 14856672
720 4783 82454268
19350 16874 302197874
23070 587 152749170
1891 14547 289440671
1166 8190 140338484
21716 9185 298976535
11870 25172 136584350
25716 29242 830786125
11648 29655 56573959...

output:

3013832575463
3009902315271
3012645567269
3012343132381
3008648070076
3010576750132
3017236340751
3008289355498
3007138904957
3007138904957
3016194424078
3017881884726
3010655112368
3016037059397
3013737792773
3019006883177
3012560368404
3015216061658
3009506414225
3010308687813
3019901770296
301163...

result:

ok 100000 lines

Test #32:

score: 0
Accepted
time: 163ms
memory: 20600kb

input:

100000 19020
6717 16507 475669175
6717 20729 299644872
6717 18582 365356233
6717 12225 19606873
6717 27920 18220440
6717 16778 435068764
6717 22087 203309155
29027 32021 400753584
8803 1537 67492941
6717 20563 289475801
6717 26502 579719371
6717 12769 19118190
6717 30321 177754766
3544 414 125376165...

output:

19590359034748
19590359034748
19590359034748
19590377630511
19590862892341
19590497361844
19590620782510
19590883704223
19590494533276
19590359034748
19590462648023
19590359034748
19590359034748
19590359034748
19590493338338
19590359034748
19590359034748
19590474988068
19590686626113
19590359034748
...

result:

ok 100000 lines

Test #33:

score: 0
Accepted
time: 152ms
memory: 19364kb

input:

100000 7548
21764 14941 74
3221 8276 752
29769 3520 648
3514 4312 845
6174 9099 150
15662 15596 37
28610 13473 902
10752 12149 56
17698 764 752
5670 31290 810
7733 518 192
26230 28014 10
14992 28728 407
4184 26152 538
6210 28659 600
4404 12802 70
6212 5777 474
23825 6639 7
14229 22882 612
1679 9139 ...

output:

4497328284734
4497328284560
4497328284012
4497328285316
4497328285126
4497328284012
4497328284012
4497328284315
4497328284320
4497328284461
4497328285335
4497328285231
4497328284012
4497328285680
4497328285435
4497328284566
4497328284012
4497328285731
4497328284012
4497328284880
4497328284750
449732...

result:

ok 100000 lines

Test #34:

score: 0
Accepted
time: 166ms
memory: 21888kb

input:

100000 27791
23816 22241 12342123
29166 29596 601699826
30081 23541 728098182
10460 31646 10079500
6494 22422 29345397
14906 17012 201274347
15645 25219 23809708
22551 29367 93259687
24405 22688 4588834
26563 27353 42076845
289 26922 55749408
17309 1317 295339982
31204 24149 18125835
20243 12595 146...

output:

23922892921101
23922626611571
23922626611571
23922626611571
23922626611571
23922626611571
23922626611571
23922626611571
23922626611571
23922626611571
23922626611571
23922626611571
23922868383101
23922626611571
23922626611571
23922626611571
23922626611571
23922626611571
23922627665547
23922626611571
...

result:

ok 100000 lines

Test #35:

score: 0
Accepted
time: 167ms
memory: 20672kb

input:

100000 10200
26072 17255 714542269
15898 5623 748923840
2382 21210 788285692
32273 20775 362461000
24570 31169 716384214
22086 26896 429007105
11358 23926 670348692
17364 5792 576497132
17372 31797 731638722
14989 9820 3432229
1012 3434 92853388
6296 15506 867842052
22990 7154 150953100
16184 30487 ...

output:

14808738444884
14808738444884
14808809102522
14809321144389
14808738444884
14808738444884
14808738444884
14808877752934
14808738444884
14808738444884
14808961348834
14809065822584
14808741946732
14809017510900
14809560773734
14808918160888
14809196117214
14808738444884
14808738444884
14808738444884
...

result:

ok 100000 lines

Test #36:

score: 0
Accepted
time: 82ms
memory: 17372kb

input:

100000 128
16856 29290 256664331
30063 11360 222800496
31863 10850 450258081
14370 2982 314087072
12389 19213 2268588
13628 3272 2965520
11778 17059 472627818
13879 131 193752880
2552 16597 385000510
10633 10458 879744060
4118 23912 833438888
7568 31316 22900320
15865 3418 162846624
13714 6744 38478...

output:

7261955901275
7250015403642
7253837022352
7250015403642
7255310202008
7272944691058
7275142261524
7261935963696
7261198692381
7254456996203
7254267788917
7282503108010
7256769482310
7250015403642
7254318794748
7260120441443
7256965105977
7279683745347
7255622452018
7255745834883
7261476599461
725807...

result:

ok 100000 lines