Conic Section
Time limit3sMemory limit256 MB
Points (i, y) receive single-point updates and range reflections of y, and each query asks for the max of a*x + b*y + c*x*y over an x-range.
- Level
Hard9 of 10
- Topics
- Segment tree, Geometry, Implementation
- Solved
- No attempts yet
Problem
Rikka generates an integer sequence as follows. She first generates with , then sets .
Initially, there are points on the Cartesian plane. The -th point has coordinates . Then operations are performed in order. The -th operation is one of three types: C, R, or Q.
Let and .
- If the -th operation is
C, replace the -th point with . - If the -th operation is
R, replace every point with by . - If the -th operation is
Q, consider all currently existing points with . Given , , and , find over these points.
Input
The first line contains three integers , , and (, , , ).
Each of the following lines starts with a character , the type of the operation, which is C, R, or Q. If is Q, three integers , , follow (, ).
It is guaranteed that the number of Q operations does not exceed .
Output
For each Q operation, output the maximum value on one line.
Hint
Initially, the three points are at , , and . The first operation changes the third point to .