7453: Dynamic Convex Hull

内存限制:128 MB 时间限制:1 S
题面:传统 评测方式:文本比较 上传者:
提交:0 通过:0

题目描述

Let’s fifirst see a related classical algorithm to help you solve this problem: You will be given n functions
f1(x), f2(x), . . . , fn(x), where fi(x) = aix + bi . When you want to fifind the minimum value of fi(x) for a
fifixed parameter x, you just need to fifind the corresponding function on the convex hull.
Now you will be given n functions f1(x), f2(x), . . . , fn(x), where fi(x) = (x x ai)4 + bi.
You need to perform the following operations for m times:
• “1 a b” (1 ≤ a ≤ 50 000, 1 ≤ b ≤ 1018): Add a new function fn+1(x) = (xxa)4 +b and then change
n into n + 1.
• “2 t” (1 ≤ t ≤ n): Delete the function ft(x). It is guaranteed that each function won’t be deleted
more than once.
• “3 x” (1 ≤ x ≤ 50 000): Query for the minimum value of fi(x), where 1 ≤ i ≤ n and the function
fi(x) has not been deleted yet.

输入格式

The fifirst line of the input contains a single integer T (1 ≤ T ≤ 5), the number of test cases.
For each case, the fifirst line of the input contains two integers n and m (1 ≤ n, m ≤ 100 000), denoting
the number of functions and the number of operations.
Each of the following n lines contains two integers ai and bi (1 ≤ ai ≤ 50 000, 1 ≤ bi ≤ 10^18), denoting
the i-th function fi(x).
Each of the next m lines describes an operation in formats described in the statement above

输出格式

For each query, print a single line containing an integer, denoting the minimum value of fi(x). Note that
when there is no functions, print “-1” instead.

输入样例 复制

1
2 8
3 9
6 100
3 4
2 1
3 4
1 1 1
3 4
2 2
2 3
3 4

输出样例 复制

10
116
82
-1

分类标签