結果

問題 No.2200 Weird Shortest Path
ユーザー hiryuNhiryuN
提出日時 2023-01-29 14:21:39
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 471 bytes
コンパイル時間 310 ms
コンパイル使用メモリ 10,972 KB
実行使用メモリ 26,828 KB
最終ジャッジ日時 2023-09-11 22:20:41
合計ジャッジ時間 5,841 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
12,256 KB
testcase_01 AC 16 ms
7,808 KB
testcase_02 AC 16 ms
7,820 KB
testcase_03 AC 24 ms
8,300 KB
testcase_04 AC 48 ms
8,540 KB
testcase_05 AC 16 ms
7,872 KB
testcase_06 AC 18 ms
7,856 KB
testcase_07 AC 21 ms
7,800 KB
testcase_08 AC 35 ms
8,532 KB
testcase_09 AC 31 ms
8,296 KB
testcase_10 AC 16 ms
8,008 KB
testcase_11 AC 17 ms
7,968 KB
testcase_12 AC 17 ms
7,920 KB
testcase_13 AC 16 ms
7,984 KB
testcase_14 AC 16 ms
7,848 KB
testcase_15 AC 30 ms
8,424 KB
testcase_16 AC 16 ms
7,808 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