luogu#P8132. [ICPC2020 WF] Landscape Generator
[ICPC2020 WF] Landscape Generator
题目背景
ICPC2020 WF E
题目描述
Interactive Creative Players Collective (ICPC) is working on a new computer game for which they want to generate realistic landscapes. One of the ICPC engineers proposed an algorithm inspired by geological processes. The algorithm starts with a flat landscape and repeatedly modifies it by lifting or lowering continuous blocks, thus forming horsts (lifted blocks) and grabens (lowered blocks). The blocks to be lifted or lowered are selected at random. ICPC hopes to obtain realistic landscapes this way.
Your task is to interpret any sequence of such modifications and output the resulting landscape. The landscape is represented by a sequence of integer height values, one for each integer point from to on the -axis. Figure E.1 illustrates an example by connecting the height values with line segments.
Initially the height is at all points. This flat shape is subjected to a sequence of modifications. Each modification applies one of the following four operations with two integer parameters :
- : Raise -- increase the height by at all points between and inclusive.
- : Depress -- decrease the height by at all points between and inclusive.
- : Hill -- add a new linearly shaped hill between and .
- : Valley -- add a new linearly shaped valley between and .
Adding a hill to the current landscape works as follows. The heights at points and are increased by . If , the heights at points and are increased by . If , the heights at points and are increased by , and so on. Figure E.2 shows an example. Adding a valley works in the same way except the heights are decreased instead. The maximal change of height happens in the middle between and . If is odd, there will be two neighboring points with maximal change, otherwise just one.
输入格式
The first line of input contains two integers and , where () is the number of points, and () is the number of modifications. The points along the -axis are numbered from to . The next lines describe the modifications. Each line contains one character and two integers and , where (one of , , or ) designates the operation and and () specify its parameters.
输出格式
Output lines, where the line contains the height at point after applying all modifications in the given order.
20 13
H 12 13
D 5 18
R 13 14
R 8 16
H 2 3
V 10 19
V 3 13
R 8 13
V 3 10
D 5 18
V 11 12
R 1 6
R 14 19
1
2
0
-3
-7
-9
-11
-9
-7
-6
-6
-5
-3
-4
-5
-4
-4
-3
0
0
7 1
H 1 6
1
2
3
3
2
1
0