Range Query on a Tree ~木上の1点加算、根までの和~

EulerTour tour(N);
BIT bit(2*N);
ll Q;cin>>Q;
while(Q--){
  ll ty;cin>>ty;
  if(ty==0){
    // add
    ll v,w;cin>>v>>w;
    bit.add(tour.L[v], w);
    bit.add(tour.R[v]+1, -w);
  }
  else{
    // get sum
    ll u;cin>>u;
    ll ans = bit.sum(tour.L[u]);
    p(ans);
  }
}

f:id:peroon:20201001033952p:plain