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

GTY's game II

Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 108    Accepted Submission(s): 10


Problem Description
GTY likes playing games with ZZF. But ZZF doesn't like to play with GTY because GTY is too stupid. This time GTY invites ZZF to play games again! To avoid being laughed at by ZZF, this time GTY takes you, GTY's assistant in the game( Because you are muchsmarter than GTY). ZZF likes painting, so she drew a tree on the papar. It's so beautiful that GTY almost forgot he had a game to play... Then ZZF said, 'I could play this game with you, but you have to answer the question correctly and quickly. Or I will give you a good-man card. 'After that she drew some nodes on the tree, each of them having a value. During the game ZZF will ask you a question or let you do an operation :
$0~u~v$ : query the sum of the values of the nodes in the route$ (u, v)$
$1~u~v$ : reverse the values of the nodes in the route$ (u, v)$
For GTY doesn't want to be given a good-man card, he needs you to help him.
 

Input
In the first line there are two numbers n, the number of the nodes, and m, the number of the operations. ( $ 1 \leq n, m \leq 80000 $ )
The next line contains n numbers which are the values of the nodes. ( $ 1 \leq val_i \leq 1000 $ )
The next $n - 1$ lines describe the tree. In each line there are two numbers u and v, meaning there is an edge between u and v. ( $ 1 \leq u, v \leq n $ )
The next $m$ lines describe the queries and the operations. Each line contains three numbers $op, u, v$. Their meanings are the same as the description above.
 

Output
For each query print the ans in one line.
 

Sample Input
4 3 1 2 3 4 1 2 1 3 2 4 0 1 3 1 2 3 0 1 4
 

Sample Output
4 8
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-04-19 06:56:46, Gzip enabled