結果
問題 | No.2640 traO Stamps |
ユーザー | mkawa2 |
提出日時 | 2024-02-19 22:46:13 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 378 ms / 2,000 ms |
コード長 | 2,486 bytes |
コンパイル時間 | 374 ms |
コンパイル使用メモリ | 82,180 KB |
実行使用メモリ | 104,692 KB |
最終ジャッジ日時 | 2024-09-29 02:36:23 |
合計ジャッジ時間 | 12,391 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 39 ms
53,884 KB |
testcase_01 | AC | 37 ms
52,712 KB |
testcase_02 | AC | 38 ms
52,532 KB |
testcase_03 | AC | 37 ms
53,976 KB |
testcase_04 | AC | 36 ms
53,372 KB |
testcase_05 | AC | 37 ms
53,568 KB |
testcase_06 | AC | 307 ms
95,460 KB |
testcase_07 | AC | 306 ms
95,164 KB |
testcase_08 | AC | 314 ms
101,384 KB |
testcase_09 | AC | 262 ms
90,508 KB |
testcase_10 | AC | 342 ms
100,876 KB |
testcase_11 | AC | 287 ms
92,716 KB |
testcase_12 | AC | 297 ms
104,288 KB |
testcase_13 | AC | 283 ms
92,720 KB |
testcase_14 | AC | 351 ms
101,152 KB |
testcase_15 | AC | 305 ms
92,940 KB |
testcase_16 | AC | 288 ms
100,776 KB |
testcase_17 | AC | 325 ms
100,864 KB |
testcase_18 | AC | 285 ms
92,636 KB |
testcase_19 | AC | 333 ms
104,504 KB |
testcase_20 | AC | 332 ms
101,240 KB |
testcase_21 | AC | 287 ms
92,984 KB |
testcase_22 | AC | 346 ms
104,480 KB |
testcase_23 | AC | 308 ms
90,532 KB |
testcase_24 | AC | 378 ms
90,880 KB |
testcase_25 | AC | 336 ms
104,396 KB |
testcase_26 | AC | 300 ms
104,628 KB |
testcase_27 | AC | 298 ms
104,012 KB |
testcase_28 | AC | 292 ms
104,200 KB |
testcase_29 | AC | 301 ms
104,284 KB |
testcase_30 | AC | 343 ms
104,436 KB |
testcase_31 | AC | 347 ms
104,692 KB |
testcase_32 | AC | 345 ms
97,888 KB |
testcase_33 | AC | 351 ms
101,120 KB |
ソースコード
import sys # sys.setrecursionlimit(1000005) # sys.set_int_max_str_digits(200005) int1 = lambda x: int(x)-1 pDB = lambda *x: print(*x, end="\n", file=sys.stderr) p2D = lambda x: print(*x, sep="\n", end="\n\n", file=sys.stderr) def II(): return int(sys.stdin.readline()) def LI(): return list(map(int, sys.stdin.readline().split())) def LLI(rows_number): return [LI() for _ in range(rows_number)] def LI1(): return list(map(int1, sys.stdin.readline().split())) def LLI1(rows_number): return [LI1() for _ in range(rows_number)] def SI(): return sys.stdin.readline().rstrip() dij = [(0, 1), (-1, 0), (0, -1), (1, 0)] # dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)] # inf = -1-(-1 << 31) inf = -1-(-1 << 62) # md = 10**9+7 md = 998244353 class BitSum: def __init__(self, n): self._n = n+1 self._table = [0]*self._n self._origin = [0]*n def __getitem__(self, item): return self._origin[item] def __setitem__(self, index, value): self.add(index, value-self._origin[index]) self._origin[index] = value def add(self, i, x): if x == 0: return self._origin[i] += x i += 1 while i < self._n: self._table[i] += x i += i & -i def sum(self, r): res = 0 while r > 0: res += self._table[r] r -= r & -r return res def sumlr(self, l, r): if l >= r: return 0 if l == 0: return self.sum(r) return self.sum(r)-self.sum(l) # return "min(i) of sum(a[0]..a[i])>=x" or "N" def bisect(self, x): idx = 0 d = 1 << (self._n-1).bit_length()-1 while d: if idx | d < self._n and self._table[idx | d] < x: idx |= d x -= self._table[idx] d >>= 1 return idx n, m, k = LI() ss = LI1() dd = [[inf]*n for _ in range(n)] for _ in range(m): u, v, c = LI() u, v = u-1, v-1 dd[u][v] = dd[v][u] = min(dd[u][v], c) for u in range(n): dd[u][u] = 0 for v in range(n): for u in range(n): for w in range(n): dd[u][w] = min(dd[u][w], dd[u][v]+dd[v][w]) bit = BitSum(k) for i, (s, t) in enumerate(zip(ss, ss[1:])): bit[i] = dd[s][t] for _ in range(II()): t, x, y = LI() if t == 2: print(bit.sumlr(x, y)) else: i = x ss[i] = y-1 if i: bit[i-1] = dd[ss[i-1]][ss[i]] if i+1 <= k: bit[i] = dd[ss[i+1]][ss[i]]