結果

問題 No.2640 traO Stamps
ユーザー cho435cho435
提出日時 2024-02-21 00:21:56
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 276 ms / 2,000 ms
コード長 985 bytes
コンパイル時間 4,531 ms
コンパイル使用メモリ 268,032 KB
実行使用メモリ 10,236 KB
最終ジャッジ日時 2024-02-21 00:22:11
合計ジャッジ時間 14,442 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 1 ms
6,676 KB
testcase_06 AC 222 ms
9,520 KB
testcase_07 AC 242 ms
9,420 KB
testcase_08 AC 257 ms
9,908 KB
testcase_09 AC 222 ms
6,912 KB
testcase_10 AC 238 ms
9,888 KB
testcase_11 AC 211 ms
7,168 KB
testcase_12 AC 261 ms
9,960 KB
testcase_13 AC 205 ms
7,296 KB
testcase_14 AC 253 ms
9,960 KB
testcase_15 AC 228 ms
7,296 KB
testcase_16 AC 211 ms
9,860 KB
testcase_17 AC 232 ms
9,900 KB
testcase_18 AC 238 ms
7,296 KB
testcase_19 AC 246 ms
10,036 KB
testcase_20 AC 242 ms
9,956 KB
testcase_21 AC 247 ms
7,296 KB
testcase_22 AC 250 ms
10,004 KB
testcase_23 AC 223 ms
7,040 KB
testcase_24 AC 236 ms
7,168 KB
testcase_25 AC 239 ms
10,112 KB
testcase_26 AC 245 ms
10,236 KB
testcase_27 AC 241 ms
10,236 KB
testcase_28 AC 231 ms
10,236 KB
testcase_29 AC 264 ms
10,236 KB
testcase_30 AC 276 ms
10,100 KB
testcase_31 AC 270 ms
10,180 KB
testcase_32 AC 255 ms
9,748 KB
testcase_33 AC 259 ms
9,852 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using mint = atcoder::modint998244353;

using S = ll;
S op(S a, S b){
	return a + b;
}
S e(){
	return 0;
}
using segtree = atcoder::segtree<S,op,e>;

int main(){
	int n,m,k;
	cin>>n>>m>>k;
	vector<int> s(k+1);
	rep(i,k+1) cin>>s.at(i);
	rep(i,k+1) s.at(i)--;
	vector<vector<ll>> g(n,vector<ll>(n,1e18));
	rep(i,m){
		int a,b,c;
		cin>>a>>b>>c;
		a--; b--;
		g.at(a).at(b)=c;
		g.at(b).at(a)=c;
	}
	rep(i,n) g.at(i).at(i)=0;
	rep(i,n) rep(j,n) rep(l,n){
		g.at(j).at(l)=min(g.at(j).at(l),g.at(j).at(i)+g.at(i).at(l));
	}
	vector<ll> ss(k);
	rep(i,k) ss.at(i)=g.at(s.at(i)).at(s.at(i+1));
	segtree seg(ss);
	int q;
	cin>>q;
	rep(Qi,q){
		int t,x,y;
		cin>>t>>x>>y;
		if(t==1){
			y--;
			s.at(x)=y;
			if(x>0) seg.set(x-1,g.at(s.at(x-1)).at(s.at(x)));
			if(x<k) seg.set(x,g.at(s.at(x)).at(s.at(x+1)));
		}else{
			cout<<seg.prod(x,y)<<"\n";
		}
	}
}
0