cogs 1583. [POJ 3237] Tree Tree maintenance chain segment tree split sleeve

1583. Maintenance [POJ 3237] tree

★★★★ Input file: maintaintree.in   Output file: a simple comparison of the time limit: 5 s memory limit: 128 MBmaintaintree.out   

Description [title]

You tree consists of N nodes thereof. Nodes of the tree are numbered from 1 to N, edges are numbered 1 to N-1. Each side has a weight. Then you have to execute a series of instructions in the trees. The instructions may be one of the following three:

CHANGE iv: the i-th weight of the side into v.

NEGATE ab: The weights of all edges in the path point a to point b value becomes its opposite number.

QUERY ab: find a maximum priority value for each point on the side of the path to point b.

[Input Format]

The first line of the input file has an integer N (N <= 10000).

Then N-1 lines each have three integers a, c has a value of the right side between the b, c, the representative points a and b. These edges from small to large are given according to their number.

Next are several instructions (no more than 10 ^ 5), are in accordance with the format mentioned above.

The last line of the input file is "DONE".

[Output format]

Each "QUERY" command, the output line, i.e. the maximum weight path on each side.

[Sample input]

3

1 2 1

2 3 2

QUERY 1 2

CHANGE 1 3

QUERY 1 2

DONE

[Sample output]

1

3

【prompt】

Here's input and output formats and POJ Uehara problem is slightly different.

【source】

POJ 3237 Tree'

 

Er er er This problem needs Chain Split + tree to solve the tree line

 

A first operation: a single point of modification  

Well, this is the basic operation of the tree line it certainly is a very simple matter will not go into details more

 Operation II: modified zone. . . That is certainly why use it to marking marking it (they want to be!) Then marking what to record? ? ?

I think that is a start tag 1 

If the interval then becomes the opposite of the case then (I guess very simple) got on a -1 -1 then multiply kept down under the subject of time and then all of a sudden take on the line ~

(<< it looks very simple but looks like it)

Operation III: finding the maximum point a to point b on the path. . ! ? ?

I used here is the chain split tree (LCA this way may be used directly at the way the recording interval becomes maximum and minimum in each of two opposite of the operation to put the maximum becomes the minimum number of minimum values ​​of the opposite in contrast to the maximum number of)

Mmm knocked try it

(Obviously now I do not have time to do it)

 

Guess you like

Origin www.cnblogs.com/Tidoblogs/p/11318158.html