#include "bits/stdc++.h" using namespace std; #define int long long #define FOR(i, a, b) for(int i=(a);i<(b);i++) #define RFOR(i, a, b) for(int i=(b-1);i>=(a);i--) #define REP(i, n) for(int i=0; i<(n); i++) #define RREP(i, n) for(int i=(n-1); i>=0; i--) #define ALL(a) (a).begin(),(a).end() #define UNIQUE_SORT(l) sort(ALL(l)); l.erase(unique(ALL(l)), l.end()); #define CONTAIN(a, b) find(ALL(a), (b)) != (a).end() #define array2(type, x, y) array, x> #define vector2(type) vector > #define out(...) printf(__VA_ARGS__) int dxy[] = {0, 1, 0, -1, 0}; /*================================*/ int N,Q; /********************************** * * Graph * **********************************/ struct Edge { int src, to, w; Edge(int u, int v, int w): src(u), to(v), w(w) {}; }; vector< vector > E(111111); int W[111111]; int D[111111]; int P[111111][20]; // 平方分割: 各番号へ、追加の重み情報が入る int S[2222]; int T[222222]; // 深さに掛ける分 int SB[2222]; int TB[222222]; // オイラーツアー: int et = 0; int LS[222222]; // iに対するTの添字(スタート時) int RS[222222]; // iに対するTの添字(終了時) void doubling() { FOR(j, 1, 20) { REP(i, N) { P[i][j] = (P[i][j-1] == -1) ? -1 : P[P[i][j-1]][j-1]; } } } void add_edge(int u, int v, int w) { E[u].push_back(*new Edge(u,v,w)); E[v].push_back(*new Edge(v,u,w)); } void dfs(int parent=-1, int i=0, int weight=0, int depth=0) { P[i][0] = parent; W[i] = weight; D[i] = depth; LS[i] = et++; for (auto e : E[i]) { if (e.to == parent) continue; dfs(i, e.to, weight + e.w, depth+1); } RS[i] = et++; } int lca(int u, int v) { // depth調整 if (D[u] > D[v]) swap(u, v); RFOR(i, 0, 20) { if ((D[v] - D[u])&(1<>N; int u,v,w; REP(i,N-1) { cin >> u >> v >> w; add_edge(u, v, w); } REP(i, N*2) T[i] = TB[i] = 0; REP(i, sqrt(N)*2+2) S[i] = SB[i] = 0; setup_tree(); cin >> Q; int c,a,b,x; REP(i,Q) { cin >> c; if (c == 1) { cin >> a >> x; add_weight(a, -x * D[a]); add_weightb(a, x); } else { cin >> b; out("%lld\n", query(b)); } } return 0; }