F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

I love tree

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 524288/524288 K (Java/Others)
Total Submission(s): 1827    Accepted Submission(s): 627


Problem Description
Given a tree with $n$ nodes and $q$ operations, there are two kinds of operations.

$1$ $a$ $b$ : for a chain <$a$, $b$>, increase the value of $x^2$ to the x-th point on this chain
for example the chain from a to b=$(x1,x2,x3,x4,x5)$,after the operation,$x1+=1,x2+=4,x3+=9,x4+=16,x5+=25$

$2$ $x$ :asks the value of x-th node
 

Input
There is only one test case for this question.

The first line contains one integer $n(1\leq n\leq 10^5)$ .

The next $n-1$ line contains two integers $u$,$v$,which means that there is an edge between $u$ and $v$.

The next line contains one integer $q(1\leq q\leq 10^5)$ .

The i-th of the following $q$ lines is in one of the 2 formats:

$1$ $a$ $b$ $(1\leq a,b\leq n)$

$2$ $x$ $(1\leq x\leq n)$
 

Output
Each line output one integer represents the answer.
 

Sample Input
3 1 2 2 3 5 1 1 2 2 1 1 2 1 2 2 2 3
 

Sample Output
1 5 0
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2025 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2025-03-31 05:25:32, Gzip enabled