QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#842648#4357. School Roadnullptr_qwq100 ✓161ms41256kbC++142.2kb2025-01-04 13:50:232025-01-04 13:50:23

Judging History

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

  • [2025-01-04 13:50:23]
  • 评测
  • 测评结果:100
  • 用时:161ms
  • 内存:41256kb
  • [2025-01-04 13:50:23]
  • 提交

answer

// 懒得写正解了哦哦哦,加个 1->n dis(1,n) 就对了

// Problem: #3806. 「JOI Open 2022」放学路
// Contest: LibreOJ
// URL: https://loj.ac/p/3806
// Memory Limit: 1024 MB
// Time Limit: 2000 ms
// 
// Powered by CP Editor (https://cpeditor.org)

// 私は猫です

#include<bits/stdc++.h>
#define int long long
#define ull unsigned long long
#define ll long long
#define pb push_back
#define mkp make_pair
#define fi first
#define se second
#define inf 1000000000
#define infll 1000000000000000000ll
#define pii pair<int,int>
#define rep(i,a,b,c) for(int i=(a);i<=(b);i+=(c))
#define per(i,a,b,c) for(int i=(a);i>=(b);i-=(c))
#define F(i,a,b) for(int i=a,i##end=b;i<=i##end;i++)
#define dF(i,a,b) for(int i=a,i##end=b;i>=i##end;i--)
#define cmh(sjy) while(sjy--)
#define lowbit(x) (x&(-x))
#define HH printf("\n")
#define eb emplace_back
#define poly vector<int>
#define SZ(x) ((int)x.size())
using namespace std;
template<typename T>inline void chkmax(T &x,const T &y){ x=std::max(x,y); }
template<typename T>inline void chkmin(T &x,const T &y){ x=std::min(x,y); }
const int mod=998244353,maxn=200005;
map<int,ll>mp[maxn];
int n,zsy,deg[maxn],vis[maxn],q[maxn],qL=1,qR=0;
void solve(){
	cin>>n>>zsy;
	F(_,1,zsy){
		int u,v,w; cin>>u>>v>>w;
		if(!mp[u].count(v))mp[u][v]=mp[v][u]=w;
		else if(mp[u][v]!=w)mp[u][v]=-1;
	}
	F(i,1,n)deg[i]=SZ(mp[i]);
	auto upd=[&](int u){ if(u>1&&u<n&&deg[u]<=2)q[++qR]=u; };
	F(i,1,n)upd(i);
	while(qL<=qR){
		const int u=q[qL++];
		if(!deg[u])continue;
		if(vis[u])continue; vis[u]=1;
		if(deg[u]==1){
			const int v=mp[u].begin()->fi;
			mp[v].erase(u),--deg[v],upd(v);
		}else if(deg[u]==2){
			const int v=mp[u].begin()->fi,w=next(mp[u].begin())->fi;
			ll val=(mp[u][v]==-1||mp[u][w]==-1)?-1:mp[u][v]+mp[u][w];
			mp[w].erase(u),mp[v].erase(u),--deg[v],--deg[w];
			if(mp[v].count(w)){
				if(mp[v][w]!=val)mp[v][w]=mp[w][v]=-1;
				upd(v),upd(w);
			}else mp[v][w]=mp[w][v]=val,++deg[v],++deg[w];
		}
	}
	if(mp[1].count(n)&&mp[1][n]!=-1&&SZ(mp[1])==1)cout<<0;
	else cout<<1;
}
signed main(){
	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	int zsy=1;
	F(____,1,zsy)solve();
}

详细

Subtask #1:

score: 7
Accepted

Test #1:

score: 7
Accepted
time: 2ms
memory: 16356kb

input:

14 40
8 12 570429827
6 10 592780730
13 14 299807355
4 10 729771483
4 10 729771483
6 9 746405411
2 3 696576351
12 14 192640790
4 13 284900209
1 2 857968292
12 14 192640790
8 12 570429827
6 10 592780730
6 9 746405411
9 11 329648726
4 13 284900209
2 3 696576351
4 10 729771483
5 11 101819611
3 7 1824073...

output:

0

result:

ok single line: '0'

Test #2:

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

input:

41 40
12 19 102666211
30 32 10931929
8 34 88862177
11 29 37284876
6 35 24117284
6 11 24483138
10 35 11019124
4 22 509961847
20 39 77098829
25 33 563195350
22 24 781289886
2 17 238185039
21 27 288940653
3 31 62767763
18 21 350694322
2 40 228181439
3 33 109276182
31 36 203571934
28 34 64098677
14 24 3...

output:

0

result:

ok single line: '0'

Test #3:

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

input:

41 40
2 21 69489336
7 32 715357509
25 38 324791430
1 39 430674626
15 40 551039547
5 18 334574228
23 37 712919654
9 27 367576234
15 38 171641096
5 36 183325856
1 6 339460052
23 26 796129406
31 35 572322695
34 35 783409641
2 4 754027046
8 33 413068373
29 33 900915508
10 13 296104622
32 39 88880510
17 ...

output:

0

result:

ok single line: '0'

Test #4:

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

input:

40 40
7 39 44916253
4 18 958910119
9 37 670785398
3 8 753908936
34 39 917194277
25 31 554847014
6 36 606005704
3 20 104555289
29 31 898892301
4 10 641381082
24 30 321262615
15 24 978365334
13 19 237154728
1 30 159127129
1 38 273921427
33 35 95259264
35 40 9238012
9 25 518899851
12 22 920531620
32 38...

output:

1

result:

ok single line: '1'

Test #5:

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

input:

30 40
19 21 328185293
13 14 22819556
2 27 273153157
14 26 50384094
11 25 494531515
25 30 359616654
11 16 375002721
18 23 164262510
5 10 407165307
11 12 711507970
1 2 848916038
7 20 859256691
8 29 134750932
26 28 47526931
3 11 113645452
9 30 342513122
17 28 80149357
13 14 22819556
3 22 124561707
11 2...

output:

1

result:

ok single line: '1'

Test #6:

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

input:

33 40
20 26 79109023
6 29 87482145
19 28 108079769
17 18 102220134
22 28 292589957
24 27 26800309
3 11 205934054
27 32 114321362
11 31 211432408
9 15 110500168
12 30 258718383
3 31 417366462
14 20 77042954
7 33 118897642
16 25 181993587
4 23 61594382
9 13 31839463
1 6 70777151
23 29 84725031
1 8 102...

output:

0

result:

ok single line: '0'

Test #7:

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

input:

41 40
8 39 632221620
7 20 764538283
14 24 639155356
28 30 568077302
13 37 522364121
4 38 92774017
1 23 37304415
2 32 863270576
9 31 747710956
24 28 827622223
25 35 157923723
23 27 782934506
20 33 753445053
29 30 194578597
11 26 191035416
7 15 59579013
3 29 184966209
15 41 203044654
11 12 164518265
1...

output:

0

result:

ok single line: '0'

Test #8:

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

input:

41 40
6 40 772449101
33 38 422577889
29 34 564405479
29 35 23989264
28 41 473451881
16 35 381757868
27 32 935802567
6 38 578727900
1 25 403637435
13 18 627709235
9 28 532310592
12 24 419349763
12 15 210295361
15 27 985536752
33 34 554957965
3 14 384539999
8 11 80181363
22 30 948552140
21 23 77411515...

output:

0

result:

ok single line: '0'

Test #9:

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

input:

41 40
9 14 360071850
14 16 781292052
14 36 602774678
14 21 320211599
14 26 860713037
14 23 760037999
14 18 426129216
14 39 137282699
11 14 939319423
14 31 150261087
1 14 192913833
7 14 238014224
14 41 104788269
8 14 443715883
14 22 449061542
14 20 350902310
14 24 919620275
12 14 816025354
13 14 3325...

output:

0

result:

ok single line: '0'

Test #10:

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

input:

28 40
16 24 629218825
17 25 565620030
14 22 533467091
15 21 352185235
10 19 400657459
4 19 479174146
5 25 612009652
1 8 102517927
13 20 474376845
18 24 168044848
9 22 295542298
21 28 42220224
15 21 352185235
16 24 629218825
14 27 834477227
23 26 191617965
2 7 763624125
3 26 498390954
12 18 3891669
1...

output:

0

result:

ok single line: '0'

Subtask #2:

score: 15
Accepted

Test #11:

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

input:

18 40
3 10 26965732
5 15 67047331
3 17 42474964
13 15 129212204
9 18 142540287
2 14 27157962
5 15 67047331
5 15 67047331
5 15 67047331
4 16 212978971
6 12 51548223
4 18 192438222
13 16 60052417
16 17 162364835
6 17 55527270
9 11 58810843
3 7 95393586
13 15 129212204
2 17 67824762
5 15 67047331
15 16...

output:

0

result:

ok single line: '0'

Test #12:

score: 15
Accepted
time: 0ms
memory: 15076kb

input:

18 51
5 16 489370441
7 8 674383722
8 11 602435525
1 10 856666364
13 18 650829027
11 14 198398173
3 4 613940394
15 17 123758204
8 11 602435525
3 6 567757815
13 18 650829027
14 15 236674174
3 4 613940394
5 18 956980171
6 16 887883755
3 6 567757815
6 16 887883755
5 18 956980171
4 10 339471731
11 14 198...

output:

0

result:

ok single line: '0'

Test #13:

score: 15
Accepted
time: 30ms
memory: 15876kb

input:

18 200000
8 17 279042056
12 13 907447344
2 16 240997679
3 7 820773384
1 5 45712022
2 16 240997679
4 18 239293113
9 14 389857788
4 18 239293113
4 18 239293113
1 11 409366186
3 12 208134361
2 16 240997679
13 17 263089947
1 5 45712022
4 18 239293113
4 7 528521172
2 9 629050323
8 17 279042056
12 13 9074...

output:

0

result:

ok single line: '0'

Test #14:

score: 15
Accepted
time: 23ms
memory: 16116kb

input:

18 200000
12 14 787958557
3 17 309856381
7 16 602540874
6 12 343810291
12 14 561222017
7 16 125534085
9 17 870511470
7 16 118408057
10 15 452922275
6 12 983055551
3 17 599421596
9 17 344601220
10 15 627856971
6 12 821612223
9 13 652746776
2 3 86605360
14 16 845498029
4 5 531236117
6 12 308924509
5 1...

output:

0

result:

ok single line: '0'

Test #15:

score: 15
Accepted
time: 26ms
memory: 15040kb

input:

18 199999
6 16 312811855
5 10 658600889
8 13 23117786
2 11 838354308
2 16 681349134
9 17 650741046
3 12 902316677
8 13 557626383
7 13 747622028
14 15 246861375
5 10 779694159
11 15 507769124
7 13 310445554
7 13 668124445
5 10 558567743
3 17 535103743
5 10 122705300
4 6 559392043
14 15 427912040
8 13...

output:

0

result:

ok single line: '0'

Test #16:

score: 15
Accepted
time: 23ms
memory: 15740kb

input:

18 200000
8 16 273673687
9 11 360275441
4 6 922867054
4 14 84928274
6 13 968233426
2 12 812572590
11 15 71503040
4 6 980374167
9 11 223188493
8 16 115328427
10 13 361608292
6 13 37132062
10 13 545962114
9 11 390680169
3 14 698353284
7 10 584994105
8 16 55684470
8 16 284428277
6 13 124379775
2 5 2317...

output:

1

result:

ok single line: '1'

Test #17:

score: 15
Accepted
time: 23ms
memory: 15020kb

input:

18 199999
6 17 135245648
9 15 341808833
12 16 429871018
4 11 210164245
7 8 123528971
11 13 31475798
2 5 483934476
2 3 23993125
11 13 620746207
14 15 930880409
2 5 351648059
9 15 472093860
12 16 465801854
14 17 211091034
14 15 736456699
4 11 420330475
14 15 60082916
6 12 376705880
12 16 882106737
14 ...

output:

1

result:

ok single line: '1'

Subtask #3:

score: 23
Accepted

Test #18:

score: 23
Accepted
time: 74ms
memory: 30268kb

input:

100000 99999
42115 93495 19881095
21969 68351 161710
7405 86343 27129
37307 45676 320013
30388 71545 117761
22026 68957 65332
77949 81644 2281387
24865 95079 341488
9849 98496 2548159
53911 79572 4962105
24880 62622 1678564
15943 22168 1524688
67424 78323 2450655
32175 74893 1908332
35640 39305 1043...

output:

0

result:

ok single line: '0'

Test #19:

score: 23
Accepted
time: 77ms
memory: 29764kb

input:

100000 100013
19959 56142 776045
6894 37840 718015
11415 73383 1519031
35732 78712 566052
78739 96739 584053
24958 28098 854234
27498 62413 1735265
27341 91341 11692771
46008 96501 299421
14384 78871 1903953
15562 33609 158393
5270 76189 69630274
38130 51331 187183
61589 75145 81438587
45138 86388 5...

output:

0

result:

ok single line: '0'

Test #20:

score: 23
Accepted
time: 69ms
memory: 29368kb

input:

100000 100013
30467 74396 2840367
12869 90814 1569862
18883 60521 211271
95973 98805 3444504
52606 61422 697591
49637 61784 1034159
21957 33982 3827036
10128 68617 444124
20731 81447 5807317
15570 35763 123607
22128 33827 59368
34479 41370 15053204
52297 55748 435155
22820 56102 66369
19316 92816 76...

output:

0

result:

ok single line: '0'

Test #21:

score: 23
Accepted
time: 68ms
memory: 29472kb

input:

100000 100013
6205 55122 513428
28020 94742 60755466
48078 86373 1325655
61744 68231 26052939
37580 98090 9672421
212 97377 3362861
54617 85198 820827
18698 55299 25810204
67840 93714 1138074
30462 46234 1718665
5128 72146 9162
58950 61074 307192
51972 95908 17177745
21488 31396 49979
62397 85443 36...

output:

1

result:

ok single line: '1'

Test #22:

score: 23
Accepted
time: 65ms
memory: 29684kb

input:

100000 99999
19850 75975 943175751
21189 63299 996032089
76265 87827 660736166
36836 70989 973169671
82782 95658 415989502
45058 47250 242170764
44441 93529 960208798
13272 45503 978605084
59468 76581 686999602
52712 60469 485026032
28127 99910 514139475
14040 83145 700781506
5160 93554 709017172
32...

output:

0

result:

ok single line: '0'

Test #23:

score: 23
Accepted
time: 64ms
memory: 29268kb

input:

100000 100013
2867 88520 823893343
10166 18433 965031326
45017 46972 147676335
1424 34485 808660907
42016 87304 469583711
7697 63483 850638214
25529 90029 215431387
66607 70454 615231339
7995 66563 711608994
53466 73356 525421026
3488 63274 855858399
15596 80635 469348707
23372 63955 540766328
22261...

output:

1

result:

ok single line: '1'

Test #24:

score: 23
Accepted
time: 78ms
memory: 30144kb

input:

100000 100013
11485 70288 916431484
8930 29172 170597785
19913 81416 774118075
16974 96678 818309909
53868 89943 58795122
2038 10690 842343541
65730 66485 695828611
38358 83924 24374848
71547 98357 263110688
56221 78646 524271192
31315 48283 412640326
15928 69081 130197780
29040 75303 194906800
7825...

output:

1

result:

ok single line: '1'

Test #25:

score: 23
Accepted
time: 65ms
memory: 30204kb

input:

100000 99999
21901 29986 653007686
9122 78441 863489420
14997 72941 725644747
69562 71281 927746192
46022 74070 93487620
14594 80614 897611216
16887 77405 345170
5767 47487 201907933
12364 69163 123201479
1639 44646 584468914
5122 83639 123244460
68856 74024 848914249
35047 42279 74414781
6012 86263...

output:

0

result:

ok single line: '0'

Test #26:

score: 23
Accepted
time: 52ms
memory: 29608kb

input:

100000 99999
4110 86414 450336269
42936 93086 890811830
78296 89884 259370843
78380 79686 68069551
11785 21163 354455370
29100 87073 610089112
49594 84946 765308648
4266 67388 907705923
39626 59923 288370616
42880 98753 98659835
53953 71358 379066969
16355 37815 966746098
66866 98829 440465171
15113...

output:

0

result:

ok single line: '0'

Test #27:

score: 23
Accepted
time: 83ms
memory: 30272kb

input:

100000 99999
19098 26233 139110560
19098 64633 962431945
19098 96229 307096589
16680 19098 974469344
17247 19098 783893800
19098 79946 549071751
784 19098 514029670
19098 34551 521026044
18224 19098 131379590
19098 85701 681543677
19098 23892 687154314
19098 67724 686208834
19098 61989 220208793
190...

output:

0

result:

ok single line: '0'

Test #28:

score: 23
Accepted
time: 69ms
memory: 30140kb

input:

100000 100013
12540 68559 498667050
32184 40909 128240760
27082 48658 588570941
42751 71093 771158294
32648 88187 711696053
23287 83961 460073679
28023 46554 795259746
18422 69570 819701842
15354 27868 856603392
32635 63595 712436612
55473 95999 550525123
11217 39760 354275949
38415 81303 862713829
...

output:

0

result:

ok single line: '0'

Test #29:

score: 23
Accepted
time: 65ms
memory: 30208kb

input:

100000 100013
36442 42111 85472510
6649 62955 10165846
16493 66193 738265168
30872 91621 539123903
27838 83835 569862029
9864 55237 280502064
72386 79547 838383160
31773 59301 579274675
10299 10513 217721832
5023 63344 335407250
58114 73065 947134562
32223 49403 228533261
16744 72325 370374575
21585...

output:

0

result:

ok single line: '0'

Test #30:

score: 23
Accepted
time: 74ms
memory: 29712kb

input:

100000 100013
37563 48593 988722800
41547 50467 972194301
43396 94137 747853711
58262 89996 523108732
1500 28997 51614316
58662 74464 56983936
79725 82761 645904773
32390 74700 306725493
16429 99615 911647494
44578 49446 207411260
54334 80937 135217561
63237 64269 775103914
1778 21422 203880744
2390...

output:

0

result:

ok single line: '0'

Test #31:

score: 23
Accepted
time: 72ms
memory: 29744kb

input:

100000 100013
8291 77470 145615995
65696 80345 310877217
73409 85086 825244095
60581 69909 570877569
12830 60468 173027697
60183 71752 49127328
1481 70570 669379659
61228 72041 709343249
39719 75972 391531233
18903 22375 508145283
23103 89469 244262606
54183 91872 201362210
33281 86388 66418381
4499...

output:

0

result:

ok single line: '0'

Test #32:

score: 23
Accepted
time: 57ms
memory: 30256kb

input:

100000 100013
6471 13513 184808556
78289 87766 616804172
47849 57835 507826649
15394 17062 691495108
36777 74061 621311081
51086 65252 299585259
10071 88930 918419459
89289 94190 525867461
9439 90003 79066987
6141 45852 219862310
43785 47822 741136540
11976 90869 653094611
17443 74431 707092876
2012...

output:

1

result:

ok single line: '1'

Test #33:

score: 23
Accepted
time: 71ms
memory: 30204kb

input:

100000 100013
14699 39393 621312524
89135 96642 805229788
26458 54374 306230462
6514 27996 899621592
29007 72781 765527574
6009 29355 795070977
2917 58392 782877073
53785 55023 871992690
10960 36232 636000194
40512 82439 239745803
2672 65034 324073288
34764 90560 350122590
14579 32453 394991275
7474...

output:

1

result:

ok single line: '1'

Test #34:

score: 23
Accepted
time: 3ms
memory: 15764kb

input:

3 2
1 2 340980240
2 3 356377005

output:

0

result:

ok single line: '0'

Test #35:

score: 23
Accepted
time: 3ms
memory: 15744kb

input:

3 3
2 3 414320272
1 2 695986466
2 3 414320272

output:

0

result:

ok single line: '0'

Test #36:

score: 23
Accepted
time: 0ms
memory: 15240kb

input:

4 4
1 2 275534428
2 4 673533552
3 4 327500945
2 3 346032607

output:

0

result:

ok single line: '0'

Test #37:

score: 23
Accepted
time: 3ms
memory: 16488kb

input:

5 8
2 3 543722623
3 4 842608903
2 3 543722623
4 5 685403056
3 4 842608903
1 2 263804908
3 4 842608903
3 4 842608903

output:

0

result:

ok single line: '0'

Test #38:

score: 23
Accepted
time: 0ms
memory: 15664kb

input:

18 17
14 17 462396817
11 16 75366805
12 17 463696084
5 16 55795827
4 8 356647166
10 14 387763648
13 18 583516400
6 12 606689569
3 8 310995840
7 15 444083225
2 3 147375274
1 2 322926667
4 9 650565072
9 11 207549021
6 13 654431768
7 10 196827918
5 15 130023736

output:

0

result:

ok single line: '0'

Test #39:

score: 23
Accepted
time: 2ms
memory: 14908kb

input:

18 21
2 3 272777371
3 9 974491394
1 13 855516914
15 16 181395162
8 18 471825674
12 14 250570962
3 8 223056845
7 13 242597453
4 14 86869198
1 13 855516914
3 16 132115767
6 15 93743867
10 17 344256346
5 6 254326219
5 11 99927424
2 11 488731068
10 12 255100052
7 17 158335845
9 10 728854050
4 11 3492967...

output:

0

result:

ok single line: '0'

Test #40:

score: 23
Accepted
time: 0ms
memory: 15260kb

input:

18 26
4 16 723485344
4 14 734625481
5 10 235127951
5 14 812810222
3 17 284897077
8 11 278825490
6 9 977026713
3 10 517858925
6 15 185782722
1 16 289051829
6 11 448466866
6 8 169641376
7 12 473127462
2 17 164992628
1 16 289051829
5 10 235127951
3 10 517858925
12 18 958164419
11 15 262684144
6 11 4484...

output:

0

result:

ok single line: '0'

Test #41:

score: 23
Accepted
time: 3ms
memory: 15412kb

input:

18 31
14 17 9607578
3 16 11398138
2 14 991861
3 4 85297915
7 14 2779293
1 3 238425119
5 17 3442388
5 9 11472158
6 16 21793468
1 12 112494893
10 18 19665709
3 18 46671268
6 18 13479662
8 12 80377889
7 15 3777380
5 15 6493293
2 7 1787432
11 14 12321027
3 13 19566167
2 14 991861
13 18 27105101
3 16 113...

output:

0

result:

ok single line: '0'

Test #42:

score: 23
Accepted
time: 2ms
memory: 14812kb

input:

18 31
12 16 478726548
9 12 157340316
1 17 7948435
1 17 7948435
8 15 28799105
1 4 391908632
1 2 686841969
1 2 686841969
13 15 19166088
6 17 3054907
1 7 184311890
7 16 219091161
1 10 501807427
1 11 340238315
12 18 874923801
1 8 73416651
5 15 17592017
10 12 380322172
4 9 332880651
5 8 11207088
3 13 130...

output:

0

result:

ok single line: '0'

Test #43:

score: 23
Accepted
time: 0ms
memory: 16088kb

input:

18 31
9 16 371875991
7 18 317960557
7 16 178991474
1 13 217057555
13 17 431560442
7 8 850832149
11 18 139314388
9 12 80933683
4 15 21280102
2 10 58061608
4 8 19597506
7 16 178991474
14 15 45945355
7 11 178646169
2 3 97626980
6 9 144092753
1 8 915890948
7 18 317960557
7 8 850832149
7 11 178646169
13 ...

output:

1

result:

ok single line: '1'

Test #44:

score: 23
Accepted
time: 0ms
memory: 15480kb

input:

18 31
3 4 30565870
4 17 326176723
11 18 134887038
5 18 433964957
5 18 433964957
5 18 433964957
12 14 11756006
3 14 12026036
6 18 140933044
5 18 433964957
5 18 433964957
10 12 18388537
4 12 54347912
1 4 86322913
8 11 51075467
7 10 22621199
5 7 50232220
8 11 51075467
5 9 307798994
5 18 433964957
13 15...

output:

0

result:

ok single line: '0'

Test #45:

score: 23
Accepted
time: 0ms
memory: 14824kb

input:

18 31
10 18 589851093
4 8 42701034
13 15 263895864
2 11 99001211
6 11 142268054
1 6 513369153
6 9 114146988
10 13 468507379
1 5 295833601
6 14 156169484
10 18 589851093
10 15 204611515
7 15 35538632
4 18 167701194
4 6 127934193
3 14 289506333
9 18 181488399
1 5 295833601
10 17 118117946
5 16 1257419...

output:

1

result:

ok single line: '1'

Test #46:

score: 23
Accepted
time: 2ms
memory: 14856kb

input:

18 31
1 5 322566112
11 16 232986934
1 5 322566112
11 16 232986934
2 17 283266620
1 14 633775852
3 17 93502627
2 7 66183695
2 8 25149170
11 16 232986934
2 17 283266620
1 10 142898939
7 15 32639700
1 6 54885988
4 12 217012394
8 15 8394825
12 13 535699856
11 16 232986934
2 13 609138184
5 14 311209740
4...

output:

0

result:

ok single line: '0'

Test #47:

score: 23
Accepted
time: 3ms
memory: 16256kb

input:

18 31
9 13 50847347
3 10 9795938
3 9 34625652
1 16 110314965
13 18 96661349
9 13 50847347
13 15 58567735
3 6 255116568
4 13 32979814
4 13 32979814
2 3 429275238
1 16 110314965
1 18 365925722
11 17 15193970
1 3 872399468
9 13 50847347
17 18 5271848
4 11 43215717
13 18 96661349
2 8 283751775
14 18 847...

output:

1

result:

ok single line: '1'

Test #48:

score: 23
Accepted
time: 4ms
memory: 15556kb

input:

18 31
3 11 150914187
6 7 327611763
6 9 555132824
4 14 662215905
7 9 227521061
14 17 347665014
4 5 732613289
10 17 179245028
15 18 861797882
9 16 192706677
10 12 848356813
3 16 574230874
8 13 604369029
9 12 836971699
5 11 661427758
10 11 6434456
2 10 4497618
9 12 836971699
3 13 479302191
2 11 1936838...

output:

1

result:

ok single line: '1'

Test #49:

score: 23
Accepted
time: 3ms
memory: 15968kb

input:

18 31
11 14 607074460
14 18 698673230
4 9 561445034
2 8 460470604
14 16 938575200
12 14 143906855
9 16 867070972
1 18 254623282
14 16 938575200
3 5 303300294
1 18 254623282
5 17 847676323
4 10 520092362
5 17 847676323
1 8 772542104
1 8 772542104
14 18 698673230
5 18 509496537
8 15 26895655
8 16 2207...

output:

1

result:

ok single line: '1'

Test #50:

score: 23
Accepted
time: 0ms
memory: 15784kb

input:

18 31
6 15 381487319
10 17 728471319
2 11 913611064
15 17 738682720
13 17 41252894
2 8 280172861
3 7 112002460
3 11 595754831
4 16 694356673
16 17 975965149
13 17 41252894
1 15 472248227
2 13 776082002
5 16 310356603
14 16 149766690
13 17 41252894
6 15 381487319
16 17 975965149
1 15 472248227
3 7 11...

output:

0

result:

ok single line: '0'

Test #51:

score: 23
Accepted
time: 3ms
memory: 15712kb

input:

18 17
5 15 227443117
8 17 698107570
8 16 115491886
9 10 854462712
6 8 447198498
8 9 528163479
4 8 364039590
7 11 147545983
11 17 192929954
5 18 909546731
7 13 123043592
2 11 539037342
1 18 399956040
6 14 66610688
10 15 35503330
7 12 40532016
3 16 206609691

output:

0

result:

ok single line: '0'

Test #52:

score: 23
Accepted
time: 0ms
memory: 16208kb

input:

18 17
2 11 864731639
10 16 28196308
1 15 535274387
9 15 297637950
13 16 985222892
8 12 493754539
4 5 706278663
7 14 241773340
3 17 334837544
9 10 144524608
12 14 25502692
2 3 922440963
6 17 250581556
5 7 332892163
6 13 195862901
8 18 691074176
4 11 231591584

output:

0

result:

ok single line: '0'

Test #53:

score: 23
Accepted
time: 3ms
memory: 16424kb

input:

18 17
4 15 731843540
7 13 660335986
11 14 395326244
12 14 270046103
8 10 570864501
12 17 883290207
4 11 610467618
2 17 520672511
10 16 452110041
9 15 935292915
9 13 540391014
8 18 619099148
1 18 42412514
3 5 114129218
1 2 685338340
6 7 562572152
5 16 484820956

output:

0

result:

ok single line: '0'

Test #54:

score: 23
Accepted
time: 0ms
memory: 15600kb

input:

18 17
2 6 562839750
1 2 198257147
2 7 83415481
2 13 19948410
2 18 955372792
2 17 855969544
2 14 914889271
2 11 766771744
2 12 408561354
2 9 765386033
2 16 485898543
2 8 846832413
2 5 775038989
2 4 32508136
2 10 878001199
2 15 699991757
2 3 756364508

output:

0

result:

ok single line: '0'

Test #55:

score: 23
Accepted
time: 66ms
memory: 29428kb

input:

100000 100013
29749 95415 12054
51671 82222 33715
27828 48654 11979
32897 33996 1705
1262 27356 37113
26445 82628 2379
26771 63333 5213
7413 57204 28710
61100 90203 6995
61573 95472 5783
1892 21405 9215
14703 61545 8805
41965 44171 6229
53113 54316 15793
36120 39201 5388
6063 35506 6124
40272 68974 ...

output:

1

result:

ok single line: '1'

Test #56:

score: 23
Accepted
time: 62ms
memory: 30196kb

input:

100000 100013
29749 95415 12054
51671 82222 33715
27828 48654 11979
32897 33996 1705
1262 27356 37113
26445 82628 2379
26771 63333 5213
7413 57204 28710
61100 90203 6995
61573 95472 5783
1892 21405 9215
14703 61545 8805
41965 44171 6229
53113 54316 15793
36120 39201 5388
6063 35506 6124
40272 68974 ...

output:

1

result:

ok single line: '1'

Subtask #4:

score: 35
Accepted

Test #57:

score: 35
Accepted
time: 0ms
memory: 15580kb

input:

18 400
11 18 145314505
1 18 242896789
1 18 242896789
5 13 31030812
13 18 93451080
1 18 242896789
1 7 123378068
1 18 242896789
1 18 242896789
1 18 242896789
1 18 242896789
1 18 242896789
1 18 242896789
1 3 42183985
1 18 242896789
13 18 93451080
1 18 242896789
13 18 93451080
1 18 242896789
1 18 242896...

output:

0

result:

ok single line: '0'

Test #58:

score: 35
Accepted
time: 27ms
memory: 16084kb

input:

18 200000
1 18 758096510
1 18 758096510
1 18 758096510
1 18 758096510
1 18 758096510
1 18 758096510
1 18 758096510
1 18 758096510
1 18 758096510
1 18 758096510
1 18 758096510
1 18 758096510
1 18 758096510
1 18 758096510
1 18 758096510
1 18 758096510
1 18 758096510
1 18 758096510
1 18 758096510
1 18 ...

output:

0

result:

ok single line: '0'

Test #59:

score: 35
Accepted
time: 29ms
memory: 15728kb

input:

18 200000
1 16 142470606
1 16 142470606
1 16 142470606
1 16 142470606
1 18 403405575
1 18 403405575
1 18 403405575
1 18 403405575
1 18 403405575
1 16 142470606
1 16 142470606
1 18 403405575
1 18 403405575
1 18 403405575
1 18 403405575
1 18 403405575
1 16 142470606
1 18 403405575
1 16 142470606
16 18...

output:

1

result:

ok single line: '1'

Test #60:

score: 35
Accepted
time: 26ms
memory: 15556kb

input:

18 200000
4 9 299686894
3 5 299686894
7 8 299686894
1 16 299686894
3 17 299686894
6 9 299686894
12 15 299686894
4 14 299686894
2 5 299686894
15 16 299686894
4 9 299686894
5 17 299686894
3 5 299686894
1 12 299686894
9 13 299686894
6 16 299686894
3 4 299686894
12 17 299686894
6 11 299686894
6 16 29968...

output:

1

result:

ok single line: '1'

Test #61:

score: 35
Accepted
time: 64ms
memory: 29420kb

input:

100000 100013
58740 94702 183108
37735 80452 620754
37294 78858 10966952
37514 85983 339130
12698 97268 45544120
69733 89994 8521209
75252 91512 12575878
277 80124 76073
17061 55209 7457230
36796 62730 7849522
45347 80689 1830312
35585 68837 368255
36459 46047 4254924
70264 73565 812524
37921 93786 ...

output:

1

result:

ok single line: '1'

Test #62:

score: 35
Accepted
time: 145ms
memory: 35312kb

input:

100000 200000
6389 94276 543986
25881 32460 603154
20645 64539 4139
27806 62727 1392853
14364 61295 175740
65909 76384 35860
40746 88474 348638
35372 49809 127422
43618 50453 115413
28758 97249 167174
49253 61224 39406485
3792 20026 6179775
50603 93717 112986
34416 93394 447809
28574 46252 400986
13...

output:

0

result:

ok single line: '0'

Test #63:

score: 35
Accepted
time: 122ms
memory: 35768kb

input:

100000 200000
24725 29360 197211
44680 71239 730893
85529 87832 449578
39513 51620 1031826
77875 89486 16491
11369 29754 100365
69956 76984 719102
13087 92813 38507
49442 61243 3201165
47378 81971 85463
43814 50975 320182
9202 74616 319851
14605 71864 3312698
55212 78262 990377
27248 91330 3869294
2...

output:

1

result:

ok single line: '1'

Test #64:

score: 35
Accepted
time: 161ms
memory: 41256kb

input:

632 200000
304 518 193336272
116 330 193336272
388 561 193336272
42 444 193336272
73 210 193336272
233 234 193336272
387 415 193336272
30 522 193336272
349 566 193336272
152 299 193336272
281 284 193336272
328 460 193336272
425 623 193336272
238 555 193336272
77 205 193336272
257 483 193336272
400 4...

output:

1

result:

ok single line: '1'

Test #65:

score: 35
Accepted
time: 2ms
memory: 16580kb

input:

18 40
5 15 50975681
1 2 74937538
4 10 189052037
1 10 339538497
1 6 196128065
17 18 87791006
17 18 87791006
10 15 22357365
6 10 143410432
1 12 90560040
7 12 37957752
4 18 152090080
4 10 189052037
7 8 22323879
10 11 84245069
1 18 680680614
1 14 210991479
1 18 680680614
7 10 211020705
3 14 78015728
7 8...

output:

0

result:

ok single line: '0'

Test #66:

score: 35
Accepted
time: 4ms
memory: 15540kb

input:

14 40
4 14 201959209
1 7 643527151
13 14 404522008
1 6 302820793
13 14 404522008
2 14 638562403
3 5 296099363
1 12 347078002
7 14 614904306
1 5 109066023
1 3 405165386
13 14 404522008
1 8 282439697
13 14 404522008
10 13 301981140
3 5 296099363
1 3 405165386
3 6 102344593
3 5 296099363
1 7 643527151
...

output:

0

result:

ok single line: '0'

Test #67:

score: 35
Accepted
time: 3ms
memory: 15476kb

input:

10 40
4 10 155190875
5 6 84217558
1 4 79668122
1 10 234858997
5 10 89763187
1 8 28014408
2 10 104545101
2 9 71819408
1 10 234858997
1 4 79668122
1 10 234858997
1 4 79668122
4 10 155190875
1 10 234858997
1 10 234858997
1 4 79668122
1 10 234858997
7 10 102844530
2 9 71819408
5 6 84217558
4 10 15519087...

output:

0

result:

ok single line: '0'

Test #68:

score: 35
Accepted
time: 3ms
memory: 15200kb

input:

6 40
1 5 127753864
2 6 165487825
1 6 237608934
1 2 72121109
3 5 49940392
1 6 237608934
1 6 237608934
1 6 237608934
1 6 237608934
1 6 237608934
5 6 109855070
1 6 237608934
3 6 59914678
5 6 109855070
1 5 127753864
1 5 127753864
1 5 127753864
1 5 127753864
1 6 237608934
1 5 127753864
1 5 127753864
1 6 ...

output:

0

result:

ok single line: '0'

Test #69:

score: 35
Accepted
time: 3ms
memory: 15112kb

input:

9 40
3 7 820765894
1 3 820765894
4 8 820765894
1 6 820765894
1 8 820765894
2 5 820765894
5 7 820765894
2 3 820765894
7 9 820765894
4 5 820765894
7 8 820765894
5 6 820765894
1 5 820765894
1 6 820765894
2 7 820765894
2 6 820765894
5 8 820765894
3 5 820765894
3 8 820765894
5 9 820765894
2 4 820765894
3...

output:

1

result:

ok single line: '1'

Test #70:

score: 35
Accepted
time: 3ms
memory: 14856kb

input:

27 40
3 11 21554227
2 23 43259751
1 22 14720102
12 27 59560397
1 6 53293849
2 23 43259751
9 16 8245874
11 27 273216446
1 6 53293849
8 24 17981555
3 21 11775055
13 19 45763922
4 11 19082667
14 19 46767692
2 7 64440055
13 21 45734158
5 7 57603827
7 18 8475649
1 17 72776469
10 11 14098552
23 25 3479727...

output:

0

result:

ok single line: '0'

Test #71:

score: 35
Accepted
time: 3ms
memory: 14896kb

input:

2 1
1 2 302129880

output:

0

result:

ok single line: '0'

Test #72:

score: 35
Accepted
time: 3ms
memory: 15008kb

input:

2 2
1 2 303710711
1 2 303710711

output:

0

result:

ok single line: '0'

Test #73:

score: 35
Accepted
time: 0ms
memory: 16128kb

input:

3 4
2 3 241174708
1 2 275099430
1 3 516274138
1 3 516274138

output:

0

result:

ok single line: '0'

Test #74:

score: 35
Accepted
time: 0ms
memory: 16036kb

input:

4 5
2 4 221389228
3 4 318254756
1 3 235436705
1 3 235436705
1 2 332302233

output:

0

result:

ok single line: '0'

Test #75:

score: 35
Accepted
time: 0ms
memory: 14832kb

input:

4 6
3 4 75669978
2 3 67113642
1 2 58298560
1 4 201082180
1 4 201082180
1 4 201082180

output:

0

result:

ok single line: '0'

Test #76:

score: 35
Accepted
time: 3ms
memory: 16448kb

input:

5 6
1 4 77220535
1 2 75417384
2 5 168870904
3 5 126891262
1 5 244288288
3 4 40176491

output:

0

result:

ok single line: '0'

Test #77:

score: 35
Accepted
time: 0ms
memory: 14672kb

input:

5 7
3 4 335644701
1 3 243730807
3 5 628570052
2 5 155669565
3 5 628570052
2 4 137255786
1 5 872300859

output:

0

result:

ok single line: '0'

Test #78:

score: 35
Accepted
time: 2ms
memory: 14776kb

input:

18 31
8 17 4629967
1 9 3718690
2 6 1042805
5 8 4543223
13 17 5964666
11 12 5524351
4 9 2912286
2 3 2120380
7 16 2854314
5 18 5891742
10 15 606691
4 7 1841464
6 10 790038
14 15 831933
5 18 5891742
5 12 7354030
2 5 18399015
4 7 1841464
5 12 7354030
5 18 5891742
7 14 841993
11 12 5524351
13 17 5964666
...

output:

0

result:

ok single line: '0'

Test #79:

score: 35
Accepted
time: 0ms
memory: 16116kb

input:

2 2
1 2 1
1 2 2

output:

1

result:

ok single line: '1'

Test #80:

score: 35
Accepted
time: 4ms
memory: 15440kb

input:

18 34
8 12 6214231
4 6 577493710
10 14 129756694
6 17 6010149
2 6 742883201
6 18 60331329
3 6 62377980
2 16 9315916
3 17 56367832
14 15 7640994
9 10 10361790
6 8 206618382
6 7 601558969
8 15 124578764
4 9 98537086
6 14 338838140
6 15 331197146
1 16 57246820
12 13 71476592
3 11 736163
6 17 6010148
6 ...

output:

1

result:

ok single line: '1'

Test #81:

score: 35
Accepted
time: 4ms
memory: 15928kb

input:

18 34
8 12 6214231
4 6 577493710
10 14 129756694
6 17 6010149
2 6 742883201
1 6 60331329
3 6 62377980
2 16 9315916
3 17 56367832
14 15 7640994
9 10 10361790
6 8 206618382
6 7 601558969
8 15 124578764
4 9 98537086
6 14 338838140
6 15 331197146
16 18 57246820
12 13 71476592
3 11 736163
6 17 6010148
6 ...

output:

1

result:

ok single line: '1'

Test #82:

score: 35
Accepted
time: 4ms
memory: 15536kb

input:

18 99
5 13 1000000000
14 17 1000000000
2 6 742883201
7 13 1000000000
12 15 1000000000
3 8 1000000000
5 12 1000000000
10 13 1000000000
11 17 1000000000
6 7 601558969
12 13 1000000000
5 9 1000000000
13 14 1000000000
1 18 869777266
1 6 809445937
4 15 1000000000
3 15 1000000000
11 13 1000000000
7 9 1000...

output:

1

result:

ok single line: '1'

Test #83:

score: 35
Accepted
time: 0ms
memory: 15532kb

input:

18 99
5 13 1000000000
14 17 1000000000
2 6 742883201
7 13 1000000000
12 15 1000000000
3 8 1000000000
5 12 1000000000
10 13 1000000000
11 17 1000000000
6 7 601558969
12 13 1000000000
5 9 1000000000
13 14 1000000000
1 18 869777266
6 18 809445937
4 15 1000000000
3 15 1000000000
11 13 1000000000
7 9 100...

output:

1

result:

ok single line: '1'

Test #84:

score: 35
Accepted
time: 113ms
memory: 40016kb

input:

100000 200000
2490 93587 1507
72073 83033 348
51946 98099 455645608
19582 57583 2495
28771 62316 33854
21828 39759 794751371
27016 62418 753537084
45984 54306 706685061
39738 78391 293736822
32568 58812 199327587
37435 43715 9202
19211 80255 6058
13351 28338 923320339
35275 83476 12491
138 76683 117...

output:

1

result:

ok single line: '1'

Subtask #5:

score: 20
Accepted

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Dependency #3:

100%
Accepted

Dependency #4:

100%
Accepted

Test #85:

score: 20
Accepted
time: 126ms
memory: 33304kb

input:

80000 200000
38864 55532 26152
58137 76883 34128873
11158 61519 932502
19598 45191 178892
22189 64357 14683
63352 67804 358209
35847 44903 2248967
52965 78244 7479204
30955 47177 17385
461 3212 5392
10451 40358 4485
28728 66289 133609
43927 50752 7092799
18134 54615 441863
6066 18397 279822
24590 40...

output:

0

result:

ok single line: '0'

Test #86:

score: 20
Accepted
time: 113ms
memory: 32736kb

input:

100000 160000
8765 78188 914977
28525 65936 26107
86310 92011 3777400
18407 56799 47277
50627 94243 4576680
57978 64366 5722
65562 68647 42020
62488 83481 322
5491 20208 2840
38915 46584 117498
2003 88940 27666
39515 87695 280537
50603 69502 370393
8899 43791 4573
65884 72986 36652
23409 83509 69724...

output:

0

result:

ok single line: '0'

Test #87:

score: 20
Accepted
time: 139ms
memory: 34752kb

input:

100000 200000
27610 51470 3839166
10433 12981 18234
6380 92129 64407864
2795 92445 302462
78076 96920 1007069
54147 78564 44233
67109 83132 22576
20826 50467 801944
32850 99783 2275032
35464 63602 3536573
49584 74222 31859
24873 81165 475979
24063 68726 6340
52614 95360 63758004
25899 64597 3108379
...

output:

0

result:

ok single line: '0'

Test #88:

score: 20
Accepted
time: 159ms
memory: 34444kb

input:

100000 200000
12003 82350 735759
40291 68875 16179611
23476 84468 14214722
6320 94459 636443
83979 88869 10449646
7374 99618 3415898
16725 68045 2749828
10585 65230 12336504
2400 48175 4707303
91845 96884 56491
35510 81897 3665867
86512 93346 33023417
6413 32526 1386521
714 42523 1535518
15901 77555...

output:

0

result:

ok single line: '0'

Test #89:

score: 20
Accepted
time: 154ms
memory: 35016kb

input:

100000 200000
34953 75364 126941
38212 89155 19227840
9224 67943 6757
41107 75823 13806446
24380 37804 398707
55770 80296 49595030
28491 45473 1858
55351 67732 2248016
217 94144 143534
13842 88799 3385662
11030 27498 193505
5768 42020 15177
45273 59209 195445
5699 75785 46369
24839 97227 553900
4831...

output:

1

result:

ok single line: '1'

Test #90:

score: 20
Accepted
time: 149ms
memory: 35064kb

input:

100000 200000
25175 77011 16126401
8671 90643 9109807
11066 55767 334107
28178 33915 4632972
94648 95707 162607
68829 96655 5311606
63150 90085 213346
55187 93240 298527
42649 90473 22694145
38875 82048 1547549
37411 87212 59535
57901 61567 6634852
11310 60699 182201
13285 27082 2065885
14786 70230 ...

output:

1

result:

ok single line: '1'

Test #91:

score: 20
Accepted
time: 137ms
memory: 34672kb

input:

100000 200000
37591 74438 300375
25147 36084 10677247
1706 63580 2238984
30819 49706 12979
29923 72541 6158786
25105 51403 6862505
32452 37280 37759594
87063 92285 3364502
32858 64345 867653
31789 54400 32264891
39496 78678 4759682
47332 71770 800182
13875 81538 3008160
6684 28293 6723085
18764 4301...

output:

0

result:

ok single line: '0'

Test #92:

score: 20
Accepted
time: 153ms
memory: 35276kb

input:

100000 200000
34145 62604 2435811
30815 37403 16564408
2420 55489 91365784
40732 81962 858110
21320 32480 12844640
5255 6192 64846189
6832 9805 6440734
75261 78947 177157233
13683 46623 414622206
62066 68991 164763768
50205 52981 56497924
30719 85309 22922275
24816 44134 28908582
28988 31074 5314920...

output:

0

result:

ok single line: '0'

Test #93:

score: 20
Accepted
time: 127ms
memory: 34728kb

input:

100000 200000
10147 28342 92251876
50815 66465 130664857
10666 28091 212898448
37150 66479 84767431
49348 55023 113847602
18211 88439 513163850
31820 33279 34977371
51540 79545 16005686
27741 31396 387604665
59338 84898 405498757
5007 96578 326102358
14173 56609 44659959
4434 70520 211218636
66999 6...

output:

0

result:

ok single line: '0'

Test #94:

score: 20
Accepted
time: 104ms
memory: 29136kb

input:

100000 200000
24439 87228 8915055
12925 72821 991915869
5035 67243 536477386
26700 95249 559008728
73601 79275 591940266
7426 46857 219406011
55486 86278 194514318
26791 38024 201657694
45235 63590 983930279
14823 66490 886669484
21245 88746 830398160
40823 87597 322581245
59545 71537 381597438
1504...

output:

0

result:

ok single line: '0'

Test #95:

score: 20
Accepted
time: 75ms
memory: 24324kb

input:

66667 199998
753 24852 310360063
4683 27098 742479103
7116 56717 866021172
12756 16279 806647635
12740 38967 651800463
26753 47922 887776658
10374 36056 968382377
6813 58028 328230852
39674 56692 547047344
30534 60215 134993990
7043 12549 43595332
15825 48581 876117595
5309 14090 753555499
8392 4439...

output:

0

result:

ok single line: '0'

Test #96:

score: 20
Accepted
time: 60ms
memory: 21408kb

input:

40000 200000
31560 35453 544324522
18726 21247 286300364
24955 25394 849978013
3794 37357 701667257
1322 5603 585280374
18030 37694 390631181
9224 11564 877588402
19406 30810 865227542
25421 38313 294043202
12910 39045 636105863
21680 37257 800424367
4066 10203 864564466
9289 15804 770594429
2517 17...

output:

0

result:

ok single line: '0'

Extra Test:

score: 0
Extra Test Passed