結果

問題 No.2640 traO Stamps
ユーザー titiatitia
提出日時 2024-02-24 02:41:02
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 978 bytes
コンパイル時間 677 ms
コンパイル使用メモリ 81,572 KB
実行使用メモリ 101,728 KB
最終ジャッジ日時 2024-02-24 02:41:10
合計ジャッジ時間 7,632 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
60,136 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 38 ms
53,332 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 TLE -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
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 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

N,M,K=map(int,input().split())
S=list(map(int,input().split()))

# グラフの最短距離を全て求める(ワーシャル–フロイド法)

Distance=[[float("inf") for i in range(N+1)] for j in range(N+1)]


for i in range(M):
    i,j,t=map(int,input().split())
    Distance[i][j]=Distance[j][i]=t # 分かっている距離を書き込んでおく.

for k in range(1,N+1): # k個までの町を使ってのDisが知れているときに
    for i in range(1,N+1): # 町iと
        for j in range(i,N+1): # 町jとの最短距離は、
            length=Distance[i][k]+Distance[j][k]
            if Distance[i][j]>length:
                Distance[i][j]=Distance[j][i]=length

Q=int(input())
for tests in range(Q):
    com,x,y=map(int,input().split())

    if com==1:
        S[x]=y
    else:
        ANS=0
        for i in range(x,y):
            #print(S[i],S[i+1])
            ANS+=Distance[S[i]][S[i+1]]

        print(ANS)
0