結果

問題 No.2640 traO Stamps
ユーザー kenken714kenken714
提出日時 2024-02-19 21:48:40
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 257 ms / 2,000 ms
コード長 1,945 bytes
コンパイル時間 1,917 ms
コンパイル使用メモリ 206,620 KB
実行使用メモリ 10,212 KB
最終ジャッジ日時 2024-02-19 21:48:52
合計ジャッジ時間 11,102 ms
ジャッジサーバーID
(参考情報)
judge13 / judge16
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
7,776 KB
testcase_01 AC 3 ms
7,776 KB
testcase_02 AC 3 ms
7,776 KB
testcase_03 AC 4 ms
7,776 KB
testcase_04 AC 4 ms
7,776 KB
testcase_05 AC 3 ms
7,776 KB
testcase_06 AC 206 ms
10,212 KB
testcase_07 AC 227 ms
10,212 KB
testcase_08 AC 241 ms
10,212 KB
testcase_09 AC 212 ms
10,212 KB
testcase_10 AC 226 ms
10,212 KB
testcase_11 AC 219 ms
10,212 KB
testcase_12 AC 230 ms
10,212 KB
testcase_13 AC 218 ms
10,212 KB
testcase_14 AC 244 ms
10,212 KB
testcase_15 AC 235 ms
10,212 KB
testcase_16 AC 219 ms
10,212 KB
testcase_17 AC 211 ms
10,212 KB
testcase_18 AC 223 ms
10,212 KB
testcase_19 AC 226 ms
10,212 KB
testcase_20 AC 250 ms
10,212 KB
testcase_21 AC 205 ms
10,212 KB
testcase_22 AC 235 ms
10,212 KB
testcase_23 AC 211 ms
10,212 KB
testcase_24 AC 217 ms
10,212 KB
testcase_25 AC 226 ms
10,212 KB
testcase_26 AC 228 ms
10,212 KB
testcase_27 AC 225 ms
10,212 KB
testcase_28 AC 237 ms
10,212 KB
testcase_29 AC 247 ms
10,212 KB
testcase_30 AC 257 ms
10,212 KB
testcase_31 AC 252 ms
10,212 KB
testcase_32 AC 237 ms
10,212 KB
testcase_33 AC 239 ms
10,212 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1ll << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD (ll)1000000007
#define P pair<ll, ll>

struct SegTree { //せぐつりー!
	ll sz;
	vector<ll> dat;
	SegTree(ll n) {
		sz = 1;
		while (sz < n)sz *= 2;
		dat.resize(2 * sz - 1);//
	}
	void update(ll a, ll x) {
		a += sz - 1;//
		dat[a] = x;
		while (a > 0) {
			a = (a - 1) / 2;
			dat[a] = dat[a * 2 + 1] + dat[a * 2 + 2];//
		}
	}
	ll query(ll a, ll b, ll k = 0, ll l = 0, ll r = -1) {
		if (r < 0) r = sz;
		if (r <= a or b <= l)return 0;//
		if (a <= l and r <= b)return dat[k];//
		ll q1, q2;
		q1 = query(a, b, k * 2 + 1, l, (l + r) / 2);
		q2 = query(a, b, k * 2 + 2, (l + r) / 2, r);
		return q1 + q2;//
	}
};

SegTree seg(210000);
ll n, m, k, q, ti[210000], s[210000], d[210][210];
int main(){
    cin >> n >> m >> k;
    k++;
    REP(i, 210){
        REP(j, 210){
            if(i != j)d[i][j] = INF;
        }
    }
    REP(i, k){
        cin >> s[i];
        s[i]--;
    }
    REP(i, m){
        ll a, b, c;
        cin >> a >> b >> c;
        a--;b--;
        d[a][b] = d[b][a] = c;
    }
    REP(l, n)REP(i, n)REP(j, n)d[i][j] = min(d[i][j], d[i][l] + d[l][j]);
    REP(i, k - 1){
        seg.update(i, d[s[i]][s[i + 1]]);
    }
    cin >> q;
    REP(qq, q){
        ll t;
        cin >> t;
        if(t == 1){
            ll x, y;
            cin >> x >> y;
            y--;
            if(x != 0)seg.update(x - 1, d[s[x - 1]][y]);
            if(x != k - 1)seg.update(x, d[s[x + 1]][y]);
            s[x] = y;
        }
        else{
            ll l, r;
            cin >> l >> r;
            cout << seg.query(l, r)<<endl;
        }
    }
}
0