結果

問題 No.2640 traO Stamps
ユーザー ニックネームニックネーム
提出日時 2024-02-19 22:03:48
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 542 ms / 2,000 ms
コード長 952 bytes
コンパイル時間 249 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 104,568 KB
最終ジャッジ日時 2024-02-19 22:04:06
合計ジャッジ時間 15,854 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 32 ms
53,460 KB
testcase_01 AC 33 ms
53,460 KB
testcase_02 AC 32 ms
53,460 KB
testcase_03 AC 32 ms
53,460 KB
testcase_04 AC 37 ms
53,460 KB
testcase_05 AC 33 ms
53,460 KB
testcase_06 AC 418 ms
95,664 KB
testcase_07 AC 421 ms
95,520 KB
testcase_08 AC 511 ms
100,548 KB
testcase_09 AC 384 ms
91,020 KB
testcase_10 AC 438 ms
100,784 KB
testcase_11 AC 406 ms
93,160 KB
testcase_12 AC 463 ms
103,644 KB
testcase_13 AC 450 ms
93,264 KB
testcase_14 AC 460 ms
100,572 KB
testcase_15 AC 438 ms
93,356 KB
testcase_16 AC 420 ms
100,936 KB
testcase_17 AC 429 ms
100,952 KB
testcase_18 AC 476 ms
93,184 KB
testcase_19 AC 475 ms
103,836 KB
testcase_20 AC 425 ms
100,676 KB
testcase_21 AC 436 ms
93,232 KB
testcase_22 AC 504 ms
103,800 KB
testcase_23 AC 403 ms
91,148 KB
testcase_24 AC 468 ms
91,300 KB
testcase_25 AC 434 ms
103,984 KB
testcase_26 AC 435 ms
104,568 KB
testcase_27 AC 411 ms
104,568 KB
testcase_28 AC 396 ms
104,568 KB
testcase_29 AC 456 ms
104,568 KB
testcase_30 AC 542 ms
103,996 KB
testcase_31 AC 521 ms
104,060 KB
testcase_32 AC 460 ms
98,120 KB
testcase_33 AC 467 ms
101,036 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

class BIT:
    def __init__(self,n):
        self.n = n; self.k = [0]*(n+1)
    def a(self,i,x):
        while i<=self.n: self.k[i] += x; i += i&-i
    def s(self,i):
        t = 0
        while i>0: t += self.k[i]; i -= i&-i
        return t
    def r(self,l,r): return self.s(r)-self.s(l-1)
n,m,k = map(int,input().split())
s = [v-1 for v in map(int,input().split())]
d = [[10**18]*n for _ in range(n)]
for i in range(n): d[i][i] = 0
for _ in range(m):
    a,b,c = map(int,input().split())
    d[a-1][b-1] = d[b-1][a-1] = c
for l in range(n):
    for i in range(n):
        for j in range(n):
            d[i][j] = min(d[i][j],d[i][l]+d[l][j])
bit = BIT(k)
for i in range(1,k+1): bit.a(i,d[s[i-1]][s[i]])
for _ in range(int(input())):
    t,x,y = map(int,input().split())
    if t==1:
        if x>0: bit.a(x,d[s[x-1]][y-1]-d[s[x-1]][s[x]])
        if x<k: bit.a(x+1,d[y-1][s[x+1]]-d[s[x]][s[x+1]])
        s[x] = y-1
    if t==2: print(bit.r(x+1,y))
0