結果

問題 No.2640 traO Stamps
ユーザー maeshunmaeshun
提出日時 2024-02-20 08:41:45
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 260 ms / 2,000 ms
コード長 1,358 bytes
コンパイル時間 4,183 ms
コンパイル使用メモリ 267,456 KB
実行使用メモリ 10,236 KB
最終ジャッジ日時 2024-02-20 08:41:59
合計ジャッジ時間 12,818 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 1 ms
6,676 KB
testcase_04 AC 2 ms
6,676 KB
testcase_05 AC 2 ms
6,676 KB
testcase_06 AC 217 ms
9,520 KB
testcase_07 AC 224 ms
9,420 KB
testcase_08 AC 224 ms
9,908 KB
testcase_09 AC 194 ms
6,912 KB
testcase_10 AC 205 ms
9,888 KB
testcase_11 AC 197 ms
7,168 KB
testcase_12 AC 215 ms
9,960 KB
testcase_13 AC 176 ms
7,168 KB
testcase_14 AC 215 ms
9,960 KB
testcase_15 AC 199 ms
7,296 KB
testcase_16 AC 208 ms
9,860 KB
testcase_17 AC 200 ms
9,900 KB
testcase_18 AC 205 ms
7,168 KB
testcase_19 AC 216 ms
10,036 KB
testcase_20 AC 213 ms
9,956 KB
testcase_21 AC 211 ms
7,296 KB
testcase_22 AC 216 ms
10,004 KB
testcase_23 AC 198 ms
7,040 KB
testcase_24 AC 202 ms
7,168 KB
testcase_25 AC 210 ms
10,112 KB
testcase_26 AC 203 ms
10,236 KB
testcase_27 AC 209 ms
10,236 KB
testcase_28 AC 208 ms
10,236 KB
testcase_29 AC 228 ms
10,236 KB
testcase_30 AC 235 ms
10,100 KB
testcase_31 AC 260 ms
10,180 KB
testcase_32 AC 223 ms
9,748 KB
testcase_33 AC 235 ms
9,852 KB
権限があれば一括ダウンロードができます

ソースコード

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(k+1, -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