#P1619. I love tree

    ID: 468 传统题 1000ms 512MiB 尝试: 0 已通过: 0 难度: (无) 上传者: 标签>2021中国大学生算法设计超级联赛线段树数据结构差分树剖

I love tree

题目描述

Given a tree with nn nodes and qq operations, there are two kinds of operations.

  1. aa bb: for a chain <aa,bb>,increase the value of x2x^2 to the x-th point on this chainfor example thechain from a to bb=(x1x1,x2x2,x3x3,x4x4,x5x5),after the operation,x1+=1,x2+=4,x3+=9,x4+=16,x5+=25x1+=1,x2+=4,x3+=9,x4+=16,x5+=25
  2. xx:asks the value of x-th node

输入格式

There is only one test case for this question. The first line contains one integer n(1leqnleq105)n(1 \\leq n \\leq 10^5). The next n1n-1 line contains two integers uu,vv,which means that there is an edge between uu and vv. The first line contains one integer q(1leqqleq105)q(1 \\leq q \\leq 10^5). The i-th of the following qq lines is in one of the 2 formats:

  1. ab(1leqa,bleqn)a b(1 \\leq a,b \\leq n).
  2. x(1leqxleqn)x(1 \\leq x \\leq n).

输出格式

Each line output one integer represents the answer.

样例

3 
1 2 
2 3 
5 
1 1 2 
2 1 
1 2 1 
2 2 
2 3
1 
5 
0

提示

Add by FZSF.