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

Yuno And Irotoridori no Sekai

Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 327680/327680 K (Java/Others)
Total Submission(s): 131    Accepted Submission(s): 25


Problem Description
Yuno is playing a galgame called Irotoridori no Sekai.
It's a good game, so she decided to make a data structure problem for you.
You are given a tree with $n$ nodes, each node has a value.
You need to perform three operations:
$1~x~y$ : reverse all the value of nodes on the chain $x$ -> $y$
$2~x~y~z$ : add $z$ to the value of nodes on the chain $x$ -> $y$
$3~x~y$ Then followed by $y$ numbers $v_1,v_2, ... v_y$ : output the $v_1$th, $v_2$th, ... , $v_y$th smallest value of the nodes which distance on the tree is no more than $1$ from node $x$
 

Input
First line contains two numbers $n,m$.
Second line $n$ numbers indicating the value of the first node to the last node.
The next $n - 1$ lines, every line consists of two numbers $x,y$, indicating that there exists an edge between node $x$ and node $y$.
In the next $m$ lines, every line consists of an operation described above.
 

Output
For each query, output a number indicating the answer.
 

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

Sample Output
1 2 1 2 3 2 3 4 5 3 4 3 5
 

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-06-22 04:05:48, Gzip enabled