/* * * ^v^ * */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; using ll = long long int; using ld = long double; #define iamtefu ios_base::sync_with_stdio(false); cin.tie(0); #define fl(i,a,n) for (ll i{a}; i=a; i--) #define ty int _; for(cin>>_; _--;) #define print(a) for(auto ele:a){cout< inline bool chmax(L &a, R b){if (a inline bool chmin(L &a, R b){if (a>b){a=b;return 1;}return 0;} template ostream& operator<<(ostream &fout, const pair &p){ fout<<"{"< ostream& operator<<(ostream &fout, const tuple &p){ auto &[l, r, u] = p; fout<<"{"< ostream& operator<<(ostream &fout, const vector &v){ for (auto &x:v){ fout< ostream& operator<<(ostream &fout, const set &st){ for (auto &x:st){ fout< ostream& operator<<(ostream &fout, const multiset &st){ for (auto &x:st){ fout< ostream& operator<<(ostream &fout, const map &mp){ fout<<"["; for (auto &[x,y]:mp){ fout<>n>>m>>k; k++; vector a(k); fl(i,0,k){ cin>>a[i]; } vector > dis(n+1, vector (n+1, 1e18)); fl(i,0,n+1){ dis[i][i]=0; } fl(i,0,m){ ll u, v, w; cin>>u>>v>>w; dis[u][v] = dis[v][u] = w; } fl(k,0,n+1){ fl(i,0,n+1){ fl(j,0,n+1){ chmin(dis[i][j], (dis[i][k]+dis[k][j])); } } } vector arr(k+1); fl(i,1,k){ arr[i+1] = dis[a[i]][a[i-1]]; } vector fen(k+1); auto ad=[&](ll i, ll x)->void{ while (i<=k){ fen[i]+=x; i+=(i&(-i)); } }; auto su=[&](ll i)->ll{ ll ret = 0; while (i>0){ ret+=fen[i]; i-=(i&(-i)); } return ret; }; fl(i,1,k+1){ ad(i, arr[i]); } ll q; cin>>q; fl(i,0,q){ // cout<>t>>x>>y; if (t==1){ x++; if (x>1){ ad(x, -arr[x]); } if (x+1<=k){ ad(x+1, -arr[x+1]); } if (x>1){ arr[x] = dis[a[x-2]][y]; } if (x+1<=k){ arr[x+1] = dis[y][a[x]]; } if (x>1){ ad(x, arr[x]); } if (x+1<=k){ ad(x+1, arr[x+1]); } a[x-1]=y; } else { x++;y++; cout<(t2-t1).count(); ti*=1e-6; cerr<<"Time: "<