結果

問題 No.2640 traO Stamps
ユーザー kwm_tkwm_t
提出日時 2024-02-19 21:49:23
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 173 ms / 2,000 ms
コード長 1,920 bytes
コンパイル時間 4,905 ms
コンパイル使用メモリ 313,672 KB
実行使用メモリ 10,132 KB
最終ジャッジ日時 2024-02-19 21:49:36
合計ジャッジ時間 11,892 ms
ジャッジサーバーID
(参考情報)
judge13 / 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 2 ms
6,676 KB
testcase_05 AC 3 ms
6,676 KB
testcase_06 AC 142 ms
9,416 KB
testcase_07 AC 153 ms
9,316 KB
testcase_08 AC 156 ms
9,804 KB
testcase_09 AC 137 ms
6,912 KB
testcase_10 AC 161 ms
9,784 KB
testcase_11 AC 131 ms
7,040 KB
testcase_12 AC 161 ms
9,856 KB
testcase_13 AC 126 ms
7,168 KB
testcase_14 AC 156 ms
9,856 KB
testcase_15 AC 147 ms
7,168 KB
testcase_16 AC 134 ms
9,756 KB
testcase_17 AC 152 ms
9,796 KB
testcase_18 AC 149 ms
7,168 KB
testcase_19 AC 156 ms
9,932 KB
testcase_20 AC 162 ms
9,852 KB
testcase_21 AC 140 ms
7,168 KB
testcase_22 AC 157 ms
9,900 KB
testcase_23 AC 143 ms
6,912 KB
testcase_24 AC 154 ms
7,040 KB
testcase_25 AC 145 ms
10,008 KB
testcase_26 AC 163 ms
10,132 KB
testcase_27 AC 172 ms
10,132 KB
testcase_28 AC 146 ms
10,132 KB
testcase_29 AC 173 ms
10,132 KB
testcase_30 AC 168 ms
9,996 KB
testcase_31 AC 165 ms
10,076 KB
testcase_32 AC 154 ms
9,644 KB
testcase_33 AC 155 ms
9,748 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
//using mint = modint998244353;
//const int mod = 998244353;
//using mint = modint1000000007;
//const int mod = 1000000007;
//const int INF = 1e9;
const long long LINF = 1e18;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i,l,r)for(int i=(l);i<(r);++i)
#define rrep(i, n) for (int i = (n-1); i >= 0; --i)
#define rrep2(i,l,r)for(int i=(r-1);i>=(l);--i)
#define all(x) (x).begin(),(x).end()
#define allR(x) (x).rbegin(),(x).rend()
#define P pair<int,int>
template<typename A, typename B> inline bool chmax(A & a, const B & b) { if (a < b) { a = b; return true; } return false; }
template<typename A, typename B> inline bool chmin(A & a, const B & b) { if (a > b) { a = b; return true; } return false; }
template<typename T>
void warshallFloyd(int n, std::vector<std::vector<T>> &d, T inf) {
	for (int k = 0; k < n; ++k)for (int i = 0; i < n; ++i)for (int j = 0; j < n; ++j) {
		if (inf == d[i][k] || inf == d[k][j])continue;
		d[i][j] = std::min(d[i][j], d[i][k] + d[k][j]);
	}
}
long long op(long long a, long long b) { return a + b; }
long long e() { return 0; }
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n, m, k; cin >> n >> m >> k;
	vector<int>s(k + 1);
	rep(i, k + 1)cin >> s[i], s[i]--;
	vector d(n, vector<long long>(n, LINF));
	rep(i, n)d[i][i] = 0;
	rep(i, m) {
		int a, b, c; cin >> a >> b >> c;
		a--, b--;
		d[a][b] = c;
		d[b][a] = c;
	}
	warshallFloyd(n, d, LINF);
	vector<long long>a(k);
	rep(i, k)a[i] = d[s[i]][s[i + 1]];
	segtree<long long, op, e>seg(a);
	int q; cin >> q;
	while (q--) {
		int t, x, y; cin >> t >> x >> y;
		if (1 == t) {
			y--;
			s[x] = y;
			if (0 != x) {
				seg.set(x - 1, d[s[x - 1]][s[x]]);
			}
			if (k != x) {
				seg.set(x, d[s[x]][s[x + 1]]);
			}
		}
		else {
			long long ans = seg.prod(x, y);
			cout << ans << endl;
		}
	}
	return 0;
}
0