結果
問題 | No.2640 traO Stamps |
ユーザー | 👑 kmjp |
提出日時 | 2024-02-22 00:10:50 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 181 ms / 2,000 ms |
コード長 | 1,670 bytes |
コンパイル時間 | 2,296 ms |
コンパイル使用メモリ | 204,476 KB |
実行使用メモリ | 10,672 KB |
最終ジャッジ日時 | 2024-02-22 00:11:01 |
合計ジャッジ時間 | 9,927 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge16 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 3 ms
9,732 KB |
testcase_01 | AC | 3 ms
9,728 KB |
testcase_02 | AC | 3 ms
9,732 KB |
testcase_03 | AC | 3 ms
9,744 KB |
testcase_04 | AC | 3 ms
9,736 KB |
testcase_05 | AC | 3 ms
9,732 KB |
testcase_06 | AC | 145 ms
10,552 KB |
testcase_07 | AC | 158 ms
10,488 KB |
testcase_08 | AC | 164 ms
10,556 KB |
testcase_09 | AC | 146 ms
10,484 KB |
testcase_10 | AC | 152 ms
10,572 KB |
testcase_11 | AC | 135 ms
10,520 KB |
testcase_12 | AC | 156 ms
10,548 KB |
testcase_13 | AC | 133 ms
10,532 KB |
testcase_14 | AC | 166 ms
10,580 KB |
testcase_15 | AC | 150 ms
10,544 KB |
testcase_16 | AC | 135 ms
10,500 KB |
testcase_17 | AC | 149 ms
10,536 KB |
testcase_18 | AC | 156 ms
10,504 KB |
testcase_19 | AC | 157 ms
10,592 KB |
testcase_20 | AC | 153 ms
10,588 KB |
testcase_21 | AC | 146 ms
10,508 KB |
testcase_22 | AC | 164 ms
10,600 KB |
testcase_23 | AC | 147 ms
10,500 KB |
testcase_24 | AC | 157 ms
10,556 KB |
testcase_25 | AC | 153 ms
10,640 KB |
testcase_26 | AC | 162 ms
10,672 KB |
testcase_27 | AC | 165 ms
10,672 KB |
testcase_28 | AC | 160 ms
10,672 KB |
testcase_29 | AC | 181 ms
10,672 KB |
testcase_30 | AC | 179 ms
10,628 KB |
testcase_31 | AC | 174 ms
10,640 KB |
testcase_32 | AC | 164 ms
10,560 KB |
testcase_33 | AC | 166 ms
10,560 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; typedef signed long long ll; #define _P(...) (void)printf(__VA_ARGS__) #define FOR(x,to) for(x=0;x<(to);x++) #define FORR(x,arr) for(auto& x:arr) #define FORR2(x,y,arr) for(auto& [x,y]:arr) #define ALL(a) (a.begin()),(a.end()) #define ZERO(a) memset(a,0,sizeof(a)) #define MINUS(a) memset(a,0xff,sizeof(a)) template<class T> bool chmax(T &a, const T &b) { if(a<b){a=b;return 1;}return 0;} template<class T> bool chmin(T &a, const T &b) { if(a>b){a=b;return 1;}return 0;} //------------------------------------------------------- int N,M,K; ll E[202][202]; int S[202020]; template<class V, int ME> class BIT { public: V bit[1<<ME]; V operator()(int e) {if(e<0) return 0;V s=0;e++;while(e) s+=bit[e-1],e-=e&-e; return s;} void add(int e,V v) { e++; while(e<=1<<ME) bit[e-1]+=v,e+=e&-e;} }; BIT<ll,20> bt; void solve() { int i,j,k,l,r,x,y; string s; cin>>N>>M>>K; FOR(x,N) FOR(y,N) E[y][x]=(x==y)?0:1LL<<60; FOR(i,K+1) { cin>>S[i]; S[i]--; } FOR(i,M) { cin>>x>>y>>k; E[x-1][y-1]=E[y-1][x-1]=k; } FOR(k,N) FOR(x,N) FOR(y,N) E[x][y]=min(E[x][y],E[x][k]+E[k][y]); FOR(i,K) { bt.add(i+1,E[S[i+1]][S[i]]); } int Q; cin>>Q; while(Q--) { cin>>i>>x>>y; if(i==1) { if(x) bt.add(x,-E[S[x]][S[x-1]]); bt.add(x+1,-E[S[x]][S[x+1]]); S[x]=y-1; if(x) bt.add(x,E[S[x]][S[x-1]]); bt.add(x+1,E[S[x]][S[x+1]]); } else { cout<<bt(y)-bt(x)<<endl; } } } int main(int argc,char** argv){ string s;int i; if(argc==1) ios::sync_with_stdio(false), cin.tie(0); FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin); cout.tie(0); solve(); return 0; }