結果

問題 No.2640 traO Stamps
ユーザー kokoseikokosei
提出日時 2024-02-19 21:56:44
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,507 bytes
コンパイル時間 2,865 ms
コンパイル使用メモリ 250,980 KB
実行使用メモリ 10,004 KB
最終ジャッジ日時 2024-02-19 21:56:52
合計ジャッジ時間 7,156 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 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 57 ms
10,004 KB
testcase_27 AC 57 ms
10,004 KB
testcase_28 AC 56 ms
10,004 KB
testcase_29 AC 62 ms
10,004 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
権限があれば一括ダウンロードができます

ソースコード

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[200010];
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