#P9527. [JOIST 2022] 洒水器 / Sprinkler
[JOIST 2022] 洒水器 / Sprinkler
Background
JOISC2022 D3T2
Problem Description
JOI has many years of experience growing vegetables in his own garden, and now he plans to manage the IOI farm.
The IOI farm consists of plots of land. There are bidirectional roads connecting the plots, numbered from to . The -th road connects plots and . Any two plots are reachable from each other through the roads. Each plot has a sprinkler, and using a sprinkler can water nearby plots.
JOI plans to grow JOI Grain on the IOI farm. JOI Grain is a strange crop: when it is watered, its height changes immediately. At the same time, JOI Grain is fragile: if its height is greater than or equal to , then the top part of length breaks off immediately and falls. JOI harvests the fallen part.
Initially, JOI planted one JOI Grain of height on plot . Over the next days, JOI takes care of these JOI Grains. On day , JOI performs one of the following two operations:
- Operation : JOI uses the sprinkler on plot to water all plots whose distance to plot is at most , multiplying the height of the JOI Grain on those plots by . Since JOI Grain may keep breaking, if a JOI Grain originally has height and is watered, its height becomes .
- Operation : JOI measures the height of the JOI Grain on plot .
The distance between plots and is defined as the minimum number of roads on a path from plot to plot .
JOI wants the JOI Grain to grow as planned, so he wants to know in advance what height should be measured for each operation .
Input Format
The first line contains two integers , representing the number of plots and the breaking threshold of JOI Grain.
The next lines each contain two integers , describing a road.
The next lines each contain one integer , the initial height of the JOI Grain.
The next line contains one integer , the number of operations.
The next lines describe the operations. Line starts with , the type of the operation, followed by:
- If , this is operation , followed by three integers , representing the sprinkler plot, the watering radius, and the growth parameter.
- If , this is operation , followed by one integer , the plot whose JOI Grain needs to be measured.
Output Format
For each operation , output one integer, the expected height of the JOI Grain.
4 7
1 2
2 3
3 4
1
1
1
1
11
1 2 1 2
1 1 0 2
2 1
2 2
2 3
2 4
1 4 10 2
2 1
2 2
2 3
2 4
4
2
2
1
1
4
4
2
6 10
5 6
1 2
1 4
2 6
3 6
9
2
3
4
9
1
10
1 5 1 7
2 4
1 4 1 9
1 5 0 7
2 1
1 1 1 3
1 6 1 4
2 5
2 4
2 3
4
1
4
8
2
8 10
1 3
3 5
4 7
6 7
4 5
7 8
2 4
5
8
6
4
6
2
9
3
11
1 2 2 0
2 1
1 6 1 0
2 4
2 6
1 5 2 0
2 8
1 7 2 0
2 6
2 7
2 4
5
0
0
3
0
0
0
Hint
Sample Explanation #1.
Initially, JOI planted JOI Grain of height on all plots.
On the first day, JOI used the sprinkler on plot . The JOI Grains on plots were affected and their heights were multiplied by . The heights of the four JOI Grains became .
On the second day, JOI used the sprinkler on plot . The JOI Grain on plot was affected and its height was multiplied by . The heights of the four JOI Grains became .
On the seventh day, JOI used the sprinkler on plot . The JOI Grains on plots were affected and their heights were multiplied by . The first JOI Grain became and broke, so the heights of the four JOI Grains became .
This sample satisfies the constraints of subtasks .
Sample Explanation #2.
On the first day, JOI used the sprinkler on plot . The heights of the JOI Grains on plots were multiplied by , becoming . Therefore, the JOI Grain on plot kept breaking and its height became .
This sample satisfies the constraints of subtasks .
Sample Explanation #3.
This sample satisfies the constraints of subtasks .
Constraints.
For all testdata, it holds that:
- .
- .
- .
- Any two plots are reachable through some roads.
- .
- .
- Each is either or .
- For each with , it is guaranteed that .
- For each with , it is guaranteed that .
The detailed additional constraints and scores for subtasks are as follows:
| Subtask ID | Additional Constraints | Score |
|---|---|---|
| For all with , it is guaranteed that | ||
| For all with , it is guaranteed that | ||
| For all with , it is guaranteed that | ||
| For all with , it is guaranteed that | ||
| No additional constraints |
Translated by ChatGPT 5