結果

問題 No.2200 Weird Shortest Path
ユーザー hiryuNhiryuN
提出日時 2023-01-29 14:14:24
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 471 bytes
コンパイル時間 357 ms
コンパイル使用メモリ 87,032 KB
実行使用メモリ 78,212 KB
最終ジャッジ日時 2023-09-11 22:13:52
合計ジャッジ時間 13,229 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,572 KB
testcase_01 AC 72 ms
71,516 KB
testcase_02 AC 73 ms
71,224 KB
testcase_03 AC 89 ms
75,856 KB
testcase_04 AC 114 ms
77,764 KB
testcase_05 AC 74 ms
71,364 KB
testcase_06 AC 82 ms
75,980 KB
testcase_07 AC 87 ms
76,180 KB
testcase_08 AC 112 ms
77,644 KB
testcase_09 AC 111 ms
78,212 KB
testcase_10 AC 73 ms
71,300 KB
testcase_11 AC 74 ms
71,364 KB
testcase_12 AC 79 ms
75,716 KB
testcase_13 AC 73 ms
71,420 KB
testcase_14 AC 74 ms
71,504 KB
testcase_15 AC 112 ms
77,584 KB
testcase_16 AC 72 ms
71,380 KB
testcase_17 TLE -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

def f(a):
    b=a
    a=A[a]
    while type(a)!=int:
        b=int(a)
        a=A[int(a)]
    return [a,b]
n,m=map(int,input().split())
D=[]
A=[None]+[1]*n
for i in range(1,m+1):
    a,b,w=map(int,input().split())
    D.append([w,a,b])
D.sort()
D=[None]+D
ans=0
for i in range(1,m+1):
    q=f(D[i][1])
    w=f(D[i][2])
    if q[1]==w[1]:
        div=0
    else:
        div=q[0]*w[0]
        A[q[1]]+=A[w[1]]
        A[w[1]]=str(q[1])
    ans+=D[i][0]*div
print(ans)
    
0