#P14451. [ICPC 2025 Xi'an R] Epilogue of Happiness
[ICPC 2025 Xi'an R] Epilogue of Happiness
题目描述
As the competition was nearing its end, a banquet was held. For decoration, there was a tree with light bulbs numbered from to on it, where the -th bulb has a of . The bulbs are connected by circuits. Specifically, for each from to , there is a circuit connecting the -th bulb and the -th bulb ().
There is a row of switches that control the bulbs' lighting. Pressing the -th switch toggles the state of all bulbs on the simple path from bulb to bulb on the tree (i.e., bulbs that are on turn off, and those that are off turn on).
children will interact with the tree. The process for the -th child is described by three integers , , and :
- Initially, all bulbs are off.
- Then, the switches from the -th to the -th are pressed in sequence.
- Finally, a photo is taken of the bulbs on the simple path from to .
The of a photo is the sum of the of all bulbs that are on in the photo. Your task is to compute this value for each of the children.
输入格式
The first line of the input contains three integers , , and (), where is the number of bulbs, is the number of switches, and is the number of children.
The second line of the input contains integers (), where represents a circuit between the -th bulb and the -th bulb.
The third line of the input contains integers (), where is the \textit{beauty} of the -th bulb.
The next lines of the input describe the switches. The -th line of these contains a single integer ().
The next lines of the input describe the interaction process of the children. The -th line of these contains three integers , , and (, ).
输出格式
Output lines, each containing an integer, representing the of each photo.
5 3 7
1 2 3 3
907 609 48 670 184
2
3
5
1 2 5
1 3 3
1 3 2
2 3 1
2 3 3
2 3 4
3 3 5
48
1516
1516
0
0
0
1748
提示
For the first child:
- First, he pressed the first switch, causing the first and the second bulbs to turn on.
- Then, he pressed the second switch, causing the first and the second bulbs to turn off while the third bulb turns on.
- He took a photo of bulbs , and . In the photo, only the 3rd bulb was lit, resulting in a beauty of .
京公网安备 11011102002149号