結果
| 問題 |
No.2200 Weird Shortest Path
|
| ユーザー |
|
| 提出日時 | 2023-01-29 14:14:24 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 471 bytes |
| コンパイル時間 | 174 ms |
| コンパイル使用メモリ | 82,176 KB |
| 実行使用メモリ | 91,760 KB |
| 最終ジャッジ日時 | 2024-06-29 11:47:58 |
| 合計ジャッジ時間 | 6,879 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 15 TLE * 1 -- * 28 |
ソースコード
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)