#P114. [TFXOI Round 1] 创世纪
[TFXOI Round 1] 创世纪
Source
This problem is proposed by . All rights reserved.
Problem Source: https://www.luogu.com.cn/problem/T565382
Problem Background
Created in silence, born from chaos, blooming in darkness.
Problem Description
After the "God" created "history," He felt that there should be something meaningful in this infinitely long "history." Thus, He decided to create the "world."
This "world" consists of "lands" with heights .
An interval is called a "peak" if it satisfies:
Similarly, an interval is called a "valley" if it satisfies:
$$r-l+1\ge3,\quad \exists k\in (l,r),\quad a_l>a_{l+1}>\ldots>a_k<\ldots<a_{r-1}<a_r$$As "history" progresses, events will occur on the "world," each being one of the following 4 types:
- Query: Given , tell the "God" the number of "peak" and "valley" subintervals in .
- Land Creation: Given , perform .
- Erosion: Given , perform .
- Reshaping: Given , perform .
Special Note: If any operation causes any to fall outside , that operation is ignored.
As the "God's" agent witnessing the creation, can you answer all of the "God's" queries?
Like you, the "God" finds precision issues with real numbers uninteresting, so if , then is considered true. Note that this = is not transitive.
Input Format
The first line contains two integers .
The second line contains real numbers, representing the heights of the -th "land."
The next lines each start with an integer :
- If , this is a query, followed by two integers , representing the query interval.
- If , this is a land creation, followed by two integers and one real number , representing the interval and parameter for the operation.
- If , this is an erosion, followed by two integers and one real number , representing the interval and parameter for the operation.
- If , this is a reshaping, followed by two integers and one real number , representing the interval and parameter for the operation.
Output Format
Several lines, where the -th line contains two integers, representing the number of "peaks" and "valleys" in the interval for the -th query.
Samples
5 5
2 3 1 3 2
0 1 4
2 3 4 0.5
1 2 3 2
3 5 5 1.5
0 1 5
1 1
2 0
5 5
4.6 -0.6 3.6 -1.9 -1.5
2 2 5 2.8
3 2 3 1.0
0 3 5
1 1 1 4.4
0 2 4
0 1
0 0
Sample 1 Explanation
- Initial "world": .
- First query :
- "Peaks": , 1.
- "Valleys": , 1.
- Second erosion , the "world" becomes: .
- Third land creation , the "world" becomes: .
- Fourth reshaping , the "world" becomes: .
- Fifth query :
- "Peaks": , 2.
- No "valleys", 0.
Sample 2 Explanation
"Lands" with negative heights also exist.
Data Range
This problem uses bundled tests.
For all data:
- .
- .
- .
- .
- .
- .
Due to precision issues, it is recommended to use long double for calculations to avoid incorrect answers.
It is guaranteed that no two originally distinct adjacent numbers will become equal due to precision errors after any "erosion" operation. Thus, you do not need to handle equality caused by precision errors after multiple operations.
| Subtask No. | Special Properties | Time Limit | Points | ||
|---|---|---|---|---|---|
| None | |||||
| A | |||||
| B | |||||
| None |
- Special Property A: All and .
- Special Property B: All and .