用户输出
431
431
431
431
431
431
431
431
431
431
Special Judge 信息
Files user_out and answer differ
系统信息
Exited with return code 0
编号 | 题目 | 状态 | 分数 | 总时间 | 内存 | 代码 / 答案文件 | 提交者 | 提交时间 |
---|---|---|---|---|---|---|---|---|
#5881 | #1063. 分身游走 | Wrong Answer | 0 | 1080 ms | 10080 K | Python 3 / 1.1 K | harkerbest | 2024-08-17 17:02:15 |
import heapq
import sys
from collections import defaultdict
def prim(n, edges):
adj = defaultdict(list)
for u, v, w in edges:
adj[u].append((w, v))
adj[v].append((w, u))
min_cost = [float('inf')] * (n + 1)
min_cost[1] = 0
visited = [False] * (n + 1)
min_heap = [(0, 1)]
mst_weight = 0
while min_heap:
cost, u = heapq.heappop(min_heap)
if visited[u]:
continue
visited[u] = True
mst_weight += cost
for next_cost, v in adj[u]:
if not visited[v] and next_cost < min_cost[v]:
min_cost[v] = next_cost
heapq.heappush(min_heap, (next_cost, v))
return mst_weight
def solve(n, k, edges):
total_mst_weight = prim(n, edges)
results = []
for start_city in range(1, n + 1):
results.append(total_mst_weight)
return results
n, k = map(int, input().split())
edges = []
for _ in range(n-1):
u, v, w = map(int, input().split())
edges.append((u, v, w))
results = solve(n, k, edges)
for result in results:
print(result)
用户输出
431
431
431
431
431
431
431
431
431
431
Special Judge 信息
Files user_out and answer differ
系统信息
Exited with return code 0
用户输出
451
451
451
451
451
451
451
451
451
451
Special Judge 信息
Files user_out and answer differ
系统信息
Exited with return code 0
20 2
1 2 61
2 3 95
1 4 68
4 5 15
4 6 54
4 7 45
2 8 81
8 9 77
4 10 26
2 11 40
9 12 16
11 13 45
11 14
<53 bytes omitted>
1303
1303
1303
1303
1303
1303
1303
1303
1303
1303
1303
1303
1303
1303
1303
1303
1303
1303
1303
1303
用户输出
830
830
830
830
830
830
830
830
830
830
830
830
830
830
830
830
830
830
830
830
Special Judge 信息
Files user_out and answer differ
系统信息
Exited with return code 0
20 2
1 2 76
1 3 81
3 4 40
2 5 16
5 6 12
3 7 87
5 8 3
3 9 42
6 10 33
5 11 13
2 12 43
2 13 13
13 14 64
<49 bytes omitted>
1318
1318
1318
1318
1318
1318
1318
1318
1318
1318
1318
1318
1318
1318
1318
1318
1318
1318
1318
1318
用户输出
831
831
831
831
831
831
831
831
831
831
831
831
831
831
831
831
831
831
831
831
Special Judge 信息
Files user_out and answer differ
系统信息
Exited with return code 0
50 12
1 2 48
1 3 18
2 4 63
4 5 69
5 6 77
5 7 96
7 8 2
1 9 19
5 10 94
9 11 45
1 12 33
7 13 11
8 14 24
<309 bytes omitted>
3657
3581
3789
3789
3651
3807
3807
3811
3757
4006
4001
3840
3888
3965
3968
3968
4089
3779
3822
4054
<150 bytes omitted>
用户输出
2412
2412
2412
2412
2412
2412
2412
2412
2412
2412
2412
2412
2412
2412
2412
2412
2412
2412
2412
2412
2412
2412
2412
2412
2412
241
<122 bytes omitted>
Special Judge 信息
Files user_out and answer differ
系统信息
Exited with return code 0
50 11
1 2 46
2 3 54
2 4 24
1 5 77
2 6 5
4 7 89
7 8 57
2 9 45
2 10 6
5 11 39
6 12 66
12 13 78
1 14 89
<308 bytes omitted>
3103
2943
3391
3063
3586
2975
3468
3523
3318
2997
3713
3321
3743
3664
3567
3637
3765
3015
3673
3723
<150 bytes omitted>
用户输出
2211
2211
2211
2211
2211
2211
2211
2211
2211
2211
2211
2211
2211
2211
2211
2211
2211
2211
2211
2211
2211
2211
2211
2211
2211
221
<122 bytes omitted>
Special Judge 信息
Files user_out and answer differ
系统信息
Exited with return code 0
50 12
1 2 20
2 3 75
3 4 51
3 5 51
1 6 88
5 7 34
6 8 96
5 9 16
8 10 56
2 11 64
3 12 8
2 13 82
4 14 93
<311 bytes omitted>
3955
3904
4167
4481
4350
4398
4486
4609
4446
4757
4368
4231
4252
4795
4505
4338
4504
4669
4873
4804
<150 bytes omitted>
用户输出
2798
2798
2798
2798
2798
2798
2798
2798
2798
2798
2798
2798
2798
2798
2798
2798
2798
2798
2798
2798
2798
2798
2798
2798
2798
279
<122 bytes omitted>
Special Judge 信息
Files user_out and answer differ
系统信息
Exited with return code 0
200 20
1 2 95
2 3 24
1 4 15
1 5 58
1 6 86
4 7 5
1 8 4
7 9 22
1 10 78
5 11 64
4 12 67
11 13 11
5 14 6
<1777 bytes omitted>
15928
16836
17098
16108
16395
17390
16198
15976
16594
16922
17191
17123
17284
17057
17317
17458
1768
<1100 bytes omitted>
用户输出
10224
10224
10224
10224
10224
10224
10224
10224
10224
10224
10224
10224
10224
10224
10224
10224
10224
10224
10224
10224
10224
10
<1072 bytes omitted>
Special Judge 信息
Files user_out and answer differ
系统信息
Exited with return code 0
200 20
1 2 58
2 3 100
1 4 42
4 5 5
5 6 47
6 7 61
5 8 9
7 9 2
5 10 71
1 11 96
10 12 58
12 13 16
11 14
<1786 bytes omitted>
16921
17763
18734
16461
16391
17174
17885
16481
17915
16532
17793
17404
17633
18708
17858
16715
1729
<1100 bytes omitted>
用户输出
10259
10259
10259
10259
10259
10259
10259
10259
10259
10259
10259
10259
10259
10259
10259
10259
10259
10259
10259
10259
10259
10
<1072 bytes omitted>
Special Judge 信息
Files user_out and answer differ
系统信息
Exited with return code 0
200 20
1 2 32
2 3 29
1 4 4
2 5 18
4 6 76
2 7 77
7 8 43
6 9 56
5 10 61
4 11 61
8 12 45
9 13 50
12 14
<1756 bytes omitted>
15907
15837
16178
15907
15954
16604
16666
17203
16757
16497
16624
17571
17207
17757
16981
16234
1672
<1100 bytes omitted>
用户输出
9647
9647
9647
9647
9647
9647
9647
9647
9647
9647
9647
9647
9647
9647
9647
9647
9647
9647
9647
9647
9647
9647
9647
9647
9647
964
<872 bytes omitted>
Special Judge 信息
Files user_out and answer differ
系统信息
Exited with return code 0
200 20
1 2 42
1 3 74
1 4 35
1 5 44
1 6 99
1 7 48
1 8 10
1 9 68
1 10 20
1 11 53
1 12 88
1 13 15
1 14
<1575 bytes omitted>
17254
18010
18586
17884
18046
18934
18118
17434
18478
17614
18208
18838
17524
17470
18082
18922
1808
<1100 bytes omitted>
用户输出
9566
9566
9566
9566
9566
9566
9566
9566
9566
9566
9566
9566
9566
9566
9566
9566
9566
9566
9566
9566
9566
9566
9566
9566
9566
956
<872 bytes omitted>
Special Judge 信息
Files user_out and answer differ
系统信息
Exited with return code 0
200 20
1 2 87
1 3 34
1 4 60
1 5 26
1 6 57
1 7 42
1 8 93
1 9 55
1 10 59
1 11 65
1 12 70
1 13 3
1 14 6
<1574 bytes omitted>
18638
20204
19250
19718
19106
19664
19394
20299
19628
19700
19808
19898
18692
18746
19448
19970
2031
<1100 bytes omitted>
用户输出
10258
10258
10258
10258
10258
10258
10258
10258
10258
10258
10258
10258
10258
10258
10258
10258
10258
10258
10258
10258
10258
10
<1072 bytes omitted>
Special Judge 信息
Files user_out and answer differ
系统信息
Exited with return code 0
15000 1
1 2 14
2 3 37
3 4 82
4 5 16
5 6 31
4 7 8
3 8 2
3 9 58
5 10 49
7 11 77
11 12 33
7 13 46
6 14
<194180 bytes omitted>
1520629
1520643
1520680
1520664
1520648
1520617
1520656
1520678
1520622
1520599
1520579
1520546
1520
<119900 bytes omitted>
用户输出
760903
760903
760903
760903
760903
760903
760903
760903
760903
760903
760903
760903
760903
760903
760903
760903
760903
760903
76
<104872 bytes omitted>
Special Judge 信息
Files user_out and answer differ
系统信息
Exited with return code 0
15000 2
1 2 21
1 3 70
3 4 23
3 5 91
3 6 89
3 7 62
6 8 51
3 9 49
4 10 61
2 11 7
2 12 7
12 13 4
12 14
<194246 bytes omitted>
1504140
1504140
1504140
1504140
1504140
1504140
1504140
1504140
1504140
1504140
1504140
1504140
1504
<119900 bytes omitted>
用户输出
753147
753147
753147
753147
753147
753147
753147
753147
753147
753147
753147
753147
753147
753147
753147
753147
753147
753147
75
<104872 bytes omitted>
Special Judge 信息
Files user_out and answer differ
系统信息
Exited with return code 0
15000 20
1 2 36
1 3 38
1 4 16
1 5 26
1 6 28
1 7 49
1 8 60
1 9 58
1 10 3
1 11 54
1 12 73
1 13 52
1 14
<152640 bytes omitted>
1523120
1523768
1523804
1523408
1523588
1523624
1524002
1524200
1524164
1523174
1524092
1524434
1524
<119900 bytes omitted>
用户输出
762560
762560
762560
762560
762560
762560
762560
762560
762560
762560
762560
762560
762560
762560
762560
762560
762560
762560
76
<104872 bytes omitted>
Special Judge 信息
Files user_out and answer differ
系统信息
Exited with return code 0
15000 20
1 2 77
1 3 79
1 4 12
1 5 69
1 6 49
1 7 59
1 8 76
1 9 82
1 10 14
1 11 15
1 12 70
1 13 44
1 1
<152590 bytes omitted>
1510170
1511556
1511592
1510386
1511412
1511052
1511232
1511538
1511646
1510422
1510440
1511430
1510
<119900 bytes omitted>
用户输出
756085
756085
756085
756085
756085
756085
756085
756085
756085
756085
756085
756085
756085
756085
756085
756085
756085
756085
75
<104872 bytes omitted>
Special Judge 信息
Files user_out and answer differ
系统信息
Exited with return code 0
15000 20
1 2 100
2 3 94
3 4 12
2 5 92
5 6 62
3 7 87
7 8 35
7 9 96
1 10 71
8 11 88
10 12 46
8 13 53
1
<194039 bytes omitted>
1497129
1496432
1495734
1495810
1497039
1497768
1495642
1495686
1497134
1497000
1497014
1497320
1496
<119900 bytes omitted>
用户输出
754842
754842
754842
754842
754842
754842
754842
754842
754842
754842
754842
754842
754842
754842
754842
754842
754842
754842
75
<104872 bytes omitted>
Special Judge 信息
Files user_out and answer differ
系统信息
Exited with return code 0
15000 20
1 2 35
1 3 87
2 4 87
1 5 18
2 6 84
1 7 84
4 8 81
2 9 81
3 10 86
7 11 79
10 12 78
3 13 97
3
<194043 bytes omitted>
1486904
1487130
1487612
1487627
1487228
1488568
1486986
1488529
1488540
1488227
1487899
1489616
1489
<119900 bytes omitted>
用户输出
750824
750824
750824
750824
750824
750824
750824
750824
750824
750824
750824
750824
750824
750824
750824
750824
750824
750824
75
<104872 bytes omitted>
Special Judge 信息
Files user_out and answer differ
系统信息
Exited with return code 0
15000 20
1 2 70
1 3 93
3 4 68
1 5 42
2 6 32
6 7 23
7 8 70
7 9 18
5 10 32
10 11 85
11 12 5
11 13 83
1
<194121 bytes omitted>
1501326
1501603
1502574
1503070
1501469
1501764
1502040
1503150
1502363
1501569
1501468
1501502
1502
<119900 bytes omitted>
用户输出
757783
757783
757783
757783
757783
757783
757783
757783
757783
757783
757783
757783
757783
757783
757783
757783
757783
757783
75
<104872 bytes omitted>
Special Judge 信息
Files user_out and answer differ
系统信息
Exited with return code 0
15000 20
1 2 92
1 3 25
3 4 11
4 5 69
3 6 25
2 7 54
4 8 79
8 9 7
6 10 16
2 11 95
8 12 11
5 13 8
4 14
<194235 bytes omitted>
1509691
1510556
1509480
1509502
1510135
1509792
1511528
1510340
1510466
1510080
1512124
1510494
1510
<119900 bytes omitted>
用户输出
762241
762241
762241
762241
762241
762241
762241
762241
762241
762241
762241
762241
762241
762241
762241
762241
762241
762241
76
<104872 bytes omitted>
Special Judge 信息
Files user_out and answer differ
系统信息
Exited with return code 0