結果

問題 No.2640 traO Stamps
ユーザー maeshunmaeshun
提出日時 2024-02-20 08:41:04
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 1,356 bytes
コンパイル時間 4,611 ms
コンパイル使用メモリ 267,456 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-02-20 08:41:15
合計ジャッジ時間 9,986 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 2 ms
6,676 KB
testcase_04 AC 1 ms
6,676 KB
testcase_05 AC 2 ms
6,676 KB
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/all>
using namespace std;
using namespace atcoder;
#define rep(i, n) for(int i=0;i<(n);++i)
#define rep1(i, n) for(int i=1;i<=(n);i++)
#define ll long long
using mint = modint998244353;
using P = pair<ll,ll>;
using lb = long double;
using T = tuple<ll, ll, ll>;
#ifdef LOCAL
#  include <debug_print.hpp>
#  define dbg(...) debug_print::multi_print(#__VA_ARGS__, __VA_ARGS__)
#else
#  define dbg(...) (static_cast<void>(0))
#endif

ll op(ll a, ll b){
	return a+b;
}

ll e(){
	return 0;
}

int main()
{
	int n, m, k;
	cin >> n >> m >> k;
	const ll INF = 1e18;
	vector<int> s(n, -1);
	rep(i,k+1){
		int t;
		cin >> t;
		--t;
		s[i] = t;
	}
	vector<vector<ll>> dist(n, vector<ll>(n, INF));
	rep(i,m){
		int u, v, c;
		cin >> u >> v >> c;
		--u;--v;
		dist[u][v] = min(dist[u][v], (ll)c);
		dist[v][u] = min(dist[v][u], (ll)c);
	}
	rep(i,n)dist[i][i] = 0;
	rep(k,n)rep(i,n)rep(j,n) dist[i][j] = min(dist[i][j], dist[i][k]+dist[k][j]);
	segtree<ll, op, e> seg(k+1);
	dbg(s);
	rep(i,k) {
		seg.set(i, dist[s[i]][s[i+1]]);
	}
	int q;
	cin >> q;
	while(q--){
		int t, x, y;
		cin >> t >> x >> y;
		if(t==1){
			s[x] = --y;
			if(x-1>=0) {
				seg.set(x-1, dist[s[x-1]][s[x]]);
			}
			if(x+1<=k) {
				seg.set(x, dist[s[x]][s[x+1]]);
			}
		}
		else{
			ll ans = seg.prod(x, y);
			cout << ans << endl;
		}
	}
	return 0;
}
0