#P3309. [SDOI2014] 向量集

    ID: 2358 远端评测题 2000ms 500MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>2014线段树各省省选山东向量凸包

[SDOI2014] 向量集

Description

Maintain a set of vectors and support the following operations online:

  • A x y (x,y108|x|, |y| \le 10^8): insert the vector (x,y)(x, y).
  • Q x y l r (x,y108|x|, |y| \le 10^8, 1lrt1 \le l \le r \le t, where tt is the number of vectors already inserted): query the maximum dot product between the vector (x,y)(x, y) and each of the vectors from the ll-th to the rr-th inserted.

Initially, the set is empty.

Input Format

The first line contains an integer N(1N4×105)N (1 \le N \le 4 \times 10^5) and a character ss, representing the number of operations and the data category, respectively.

Then follow NN lines, each containing one operation in the format described above.

Note that when ss is not E, all integers in the input are encrypted. You can use the following program to obtain the original input:

inline int decode(int x, long long lastans) {    
    return x ^ (lastans & 0x7fffffff);
}

Here, xx is the number read by your program, and lastans is the answer to the most recent previous query. Before the first query, lastans is 00. Note: the dot product of vectors (x,y)(x, y) and (z,w)(z, w) is defined as xz+ywxz + yw.

Output Format

For each Q operation, output an integer representing the answer.

6 A
A 3 2
Q 1 5 1 1
A 15 14
A 12 9
Q 12 8 12 15
Q 21 18 19 18
13
17
17

Hint

Sample explanation: after decryption, the input is

    6 E
    A 3 2
    Q 1 5 1 1
    A 2 3
    A 1 4
    Q 1 5 1 2
    Q 4 3 2 3

Translated by ChatGPT 5