結果

問題 No.2640 traO Stamps
ユーザー kokoseikokosei
提出日時 2024-02-19 21:55:23
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,504 bytes
コンパイル時間 2,987 ms
コンパイル使用メモリ 250,980 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-02-19 21:55:31
合計ジャッジ時間 7,658 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 2 ms
6,676 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
testcase_32 RE -
testcase_33 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/segtree>
using namespace std;
using ll = long long;
ll inf = 1e18;

ll op(ll a, ll b) { return a + b; }
ll e() { return 0; }
using segtree = atcoder::segtree<ll, op, e>;

int N, M, K, Q;
int S[210];
ll dist[210][210];
template<typename A, int N, typename T>
void Fill(A (&arr)[N], const T &val){
    fill((T*)arr, (T*)(arr + N), val);
}
int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    cin >> N >> M >> K;
    Fill(dist, inf);
    for(int i = 0;i <= K;i++){
        cin >> S[i]; S[i]--;
    }
    for(int i = 0;i < M;i++){
        int a, b; ll c; cin >> a >> b >> c;
        a--, b--;
        dist[a][b] = min(dist[a][b], c);
        dist[b][a] = min(dist[b][a], c);
    }
    for(int k = 0;k < N;k++){
        for(int i = 0;i < N;i++){
            for(int j = 0;j < N;j++){
                dist[i][j] = min(dist[i][k] + dist[k][j], dist[i][j]);
            }
        }
    }
    segtree seg(K);
    for(int i = 0;i < K;i++){
        seg.set(i, dist[S[i]][S[i + 1]]);
    }
    cin >> Q;
    while(Q--){
        int t; cin >> t;
        if(t == 1){
            int x, y; cin >> x >> y;
            y--;
            S[x] = y;
            if(x > 0){
                seg.set(x - 1, dist[S[x - 1]][S[x]]);
            }
            if(x < K){
                seg.set(x, dist[S[x]][S[x + 1]]);
            }
        }else{
            int x, y; cin >> x >> y;
            cout << seg.prod(x, y) << "\n";
        }
    }
    return 0;
}
0