結果

問題 No.2640 traO Stamps
ユーザー shobonvipshobonvip
提出日時 2024-02-19 22:21:46
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,867 bytes
コンパイル時間 4,178 ms
コンパイル使用メモリ 267,408 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-02-19 22:21:54
合計ジャッジ時間 8,572 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 3 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 53 ms
6,676 KB
testcase_27 AC 54 ms
6,676 KB
testcase_28 AC 53 ms
6,676 KB
testcase_29 AC 57 ms
6,676 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

//* ATCODER
#include<atcoder/all>
using namespace atcoder;
typedef modint998244353 mint;
//*/

/* BOOST MULTIPRECISION
#include<boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
//*/

typedef long long ll;

#define rep(i, s, n) for (int i = (int)(s); i < (int)(n); i++)
#define rrep(i, s, n) for (int i = (int)(n)-1; i >= (int)(s); i--)

template <typename T> bool chmin(T &a, const T &b) {
	if (a <= b) return false;
	a = b;
	return true;
}

template <typename T> bool chmax(T &a, const T &b) {
	if (a >= b) return false;
	a = b;
	return true;
}

template <typename T> T max(vector<T> &a){
	assert(!a.empty());
	T ret = a[0];
	for (int i=0; i<(int)a.size(); i++) chmax(ret, a[i]);
	return ret;
}

template <typename T> T min(vector<T> &a){
	assert(!a.empty());
	T ret = a[0];
	for (int i=0; i<(int)a.size(); i++) chmin(ret, a[i]);
	return ret;
}

template <typename T> T sum(vector<T> &a){
	T ret = 0;
	for (int i=0; i<(int)a.size(); i++) ret += a[i];
	return ret;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	int n, m, k; cin >> n >> m >> k;
	vector d(n, vector<ll>(n, 1e18));

	vector<int> s(k+1);
	rep(i,0,k+1){
		cin >> s[i];
		s[i]--;
	}

	rep(i,0,m){
		int a, b; cin >> a >> b;
		a--; b--;
		ll c; cin >> c;
		chmin(d[a][b], c);
		chmin(d[b][a], c);
	}

	rep(r,0,n){
		rep(i,0,n){
			rep(j,0,n){
				chmin(d[i][j], d[i][r] + d[r][j]);
			}
		}
	}


	fenwick_tree<ll> bit(k);

	rep(i,0,k){
		bit.add(i, d[s[i]][s[i+1]]);
	}

	int q; cin >> q;
	while(q--){
		int t; cin >> t;
		int x, y; cin >> x >> y;
		if (t == 1){
			s[x] = y-1;
			if (x-1 >= 0){
				bit.add(x-1, -bit.sum(x-1, x));
				bit.add(x-1, d[s[x-1]][s[x]]);
			}
			if (x < k){
				bit.add(x, -bit.sum(x, x+1));
				bit.add(x, d[s[x]][s[x+1]]);
			}
		}else{
			cout << bit.sum(x, y) << '\n';
		}
	}
	
}

0