結果

問題 No.2640 traO Stamps
ユーザー てんぷらてんぷら
提出日時 2024-02-19 21:40:30
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 167 ms / 2,000 ms
コード長 1,534 bytes
コンパイル時間 4,506 ms
コンパイル使用メモリ 312,324 KB
実行使用メモリ 10,132 KB
最終ジャッジ日時 2024-02-19 21:40:42
合計ジャッジ時間 11,185 ms
ジャッジサーバーID
(参考情報)
judge11 / judge16
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 1 ms
6,676 KB
testcase_03 AC 1 ms
6,676 KB
testcase_04 AC 1 ms
6,676 KB
testcase_05 AC 1 ms
6,676 KB
testcase_06 AC 127 ms
9,416 KB
testcase_07 AC 164 ms
9,316 KB
testcase_08 AC 148 ms
9,804 KB
testcase_09 AC 133 ms
6,912 KB
testcase_10 AC 158 ms
9,784 KB
testcase_11 AC 123 ms
7,040 KB
testcase_12 AC 143 ms
9,856 KB
testcase_13 AC 119 ms
7,168 KB
testcase_14 AC 146 ms
9,856 KB
testcase_15 AC 135 ms
7,168 KB
testcase_16 AC 127 ms
9,756 KB
testcase_17 AC 152 ms
9,796 KB
testcase_18 AC 152 ms
7,168 KB
testcase_19 AC 147 ms
9,932 KB
testcase_20 AC 140 ms
9,852 KB
testcase_21 AC 138 ms
7,168 KB
testcase_22 AC 147 ms
9,900 KB
testcase_23 AC 133 ms
6,912 KB
testcase_24 AC 158 ms
7,040 KB
testcase_25 AC 133 ms
10,008 KB
testcase_26 AC 151 ms
10,132 KB
testcase_27 AC 150 ms
10,132 KB
testcase_28 AC 141 ms
10,132 KB
testcase_29 AC 167 ms
10,132 KB
testcase_30 AC 161 ms
9,996 KB
testcase_31 AC 154 ms
10,076 KB
testcase_32 AC 150 ms
9,644 KB
testcase_33 AC 148 ms
9,748 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0