#P8929. 「TERRA-OI R1」别得意,小子
「TERRA-OI R1」别得意,小子
Background
Midway through the battle, the blue-purple sky suddenly turned into a vast black mass. Some purple shells on the God Devourer began to fall off, turning into smaller pythons. From the moment they appeared, these little guys charged at you recklessly. After you had just cleared them out, a bloody huge mouth suddenly emerged from the mist, as the God Devourer rushed toward you......
Problem Description
You are given a piecewise function with segments. Each segment may be a linear function or a quadratic function. There are queries. Each query asks either for the value of when , or for how many intersection points the line has with the function.
Input Format
The first line contains two integers separated by spaces, representing the number of segments and the number of queries.
From line to line , first read and , meaning that the domain of this segment is (it is guaranteed that , and ). Then read one of the following two cases:
- , meaning this interval is a linear function (it is guaranteed that ).
- , meaning this interval is a quadratic function (it is guaranteed that ).
From line to line , each line contains two integers separated by spaces:
- If , output the value of when (it is guaranteed that ).
- If , output how many intersection points the line has with the whole piecewise function within the range .
Output Format
There are lines in total. Each line contains one integer, the answer to the corresponding query.
3 4
0 3 1 1 2
3 6 2 1 -2 1
6 10 1 1 0
1 4
2 5
2 114514
2 2
9
2
0
0
6 8
0 4 2 1 -4 0
4 6 1 2 -10
6 11 1 1 -19
11 19 2 -1 -30 559
19 29 1 1 -58
29 38 1 1 -68
1 11
2 4
2 -1
1 21
2 -5
2 2
1 34
2 1
-8
1
4
-37
1
2
-34
2
Hint
Sample Explanation #1
The three segments are , , and .
For , substituting into the second segment gives the result .
The line intersects the first and second segments, and each has exactly one intersection point, so the result is .
Obviously, the line corresponding to the third query does not intersect the function.
Although the line in the fourth query intersects the first segment at , is not in that segment's interval, so it is discarded.
Constraints
This problem uses bundled testdata.
| Subtask | Score | limit | |
|---|---|---|---|
| None | |||
| No query of type | |||
| No quadratic function | |||
| None |
For of the testdata, , , and .
All function coefficients are within the storage range of 64-bit signed integers, and the computation results, as well as the maximum and minimum values of any term in each function expression, will not exceed the storage range of 64-bit signed integers. All query parameters are within the range of 32-bit signed integers.
(i.e. , )
Hint
When using floating-point numbers, it is recommended to use long double to avoid precision issues.
upd: A set of hack testdata has been added. If you do not pass it, it will show as "Unaccepted 100pts".
Translated by ChatGPT 5