Dynamic Convex Hull
Time limit4sMemory limit512 MB
Maintain a set of functions (x-a)^4+b under insertions and deletions, and report the minimum value at each queried point x.
- Level
Hard9 of 10
- Topics
- Geometry, Segment tree, Divide and conquer
- Solved
- No attempts yet
Problem
First, consider a classical related algorithm. You are given functions , where . To find the minimum value of over all for a fixed parameter , you only need to find the corresponding function on the convex hull.
Now you are given functions , where . You need to perform operations. Each operation has one of the following forms:
- "1 " (, ): Add a new function , then change into .
- "2 " (): Delete the function . Each function is deleted at most once.
- "3 " (): Query the minimum value of over all whose function has not been deleted yet.
Input
The first line contains a single integer (), the number of test cases. Each test case is described as follows.
The first line contains two integers and (), the number of functions and the number of operations.
Each of the following lines contains two integers and (, ), which define the -th function .
Each of the next lines describes one operation in the format shown above.
Output
For each query, print a single line containing the minimum value of . If there are no functions, print "-1" instead.