結果
問題 | No.2640 traO Stamps |
ユーザー |
![]() |
提出日時 | 2024-02-19 21:40:30 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 177 ms / 2,000 ms |
コード長 | 1,534 bytes |
コンパイル時間 | 5,009 ms |
コンパイル使用メモリ | 313,208 KB |
実行使用メモリ | 9,992 KB |
最終ジャッジ日時 | 2024-09-29 01:35:56 |
合計ジャッジ時間 | 11,831 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 33 |
ソースコード
#include <atcoder/all> #include <bits/stdc++.h> using ll = long long; using ull = unsigned long long; #define rep(i, n) for(int i = 0; i < (int)(n); i++) #define REP(i, m, n) for(int i = (int)(m); i < (int)(n); i++) using namespace std; using namespace atcoder; using mint = modint998244353; const int inf = 1000000007; const ll longinf = 1ll << 60; ll op(ll x, ll y) { return x + y; } ll e() { return 0; } int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n, m, k; cin >> n >> m >> k; vector<int> a(k + 1); rep(i, k + 1) { cin >> a[i]; --a[i]; } vector dist(n, vector(n, 1ll << 60)); rep(i, n) dist[i][i] = 0; rep(i, m) { int x, y, z; cin >> x >> y >> z; --x; --y; dist[x][y] = z; dist[y][x] = z; } rep(i, n) rep(j, n) rep(k, n) { dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]); } segtree<ll, op, e> sg(k); rep(i, k) sg.set(i, dist[a[i]][a[i + 1]]); int q; cin >> q; while(q--) { int t; cin >> t; if(t == 1) { int i, y; cin >> i >> y; --y; a[i] = y; if(i + 1 <= k) { sg.set(i, dist[a[i]][a[i + 1]]); } if(i > 0) { sg.set(i - 1, dist[a[i - 1]][a[i]]); } } else { int x, y; cin >> x >> y; cout << sg.prod(x, y) << endl; } } return 0; }