eolymp
bolt
Try our new interface for solving problems
Problems

Quadrant Queries

Quadrant Queries

There are \textbf{n} points in the plane. The \textbf{i}-th point has coordinates (\textbf{x_i}, \textbf{y_i}). Perform the following queries, and always include the boundry points (\textbf{i} and \textbf{j}) in the operation: 1) Reflect all points between points \textbf{i} and \textbf{j} along the \textbf{X} axis. This query is represented as “\textbf{X i j}” 2) Reflect all points between points \textbf{i} and \textbf{j} along the \textbf{Y} axis. This query is represented as “\textbf{Y i j}” 3) Count how many points between points \textbf{i} and \textbf{j} lie in each of the \textbf{4} quadrants. This query is represented as “\textbf{C i j}” \InputFile The first line contains \textbf{n} (\textbf{1} ≤ \textbf{n }≤ \textbf{100000}), the number of points. \textbf{n} lines follow. The \textbf{i}-th line contains \textbf{x_i} and \textbf{y_i} separated by a space. The next line contains \textbf{q} (\textbf{1} ≤ \textbf{q} ≤ \textbf{1000000}) the number of queries. The next \textbf{q} lines contain one query each, of one of the above forms. All indices are \textbf{1} indexed. You may assume that no point lies on the \textbf{X} or the \textbf{Y} axis. All (\textbf{x_i}, \textbf{y_i}) will fit in a \textbf{32}-bit signed integer. \OutputFile Print one line for each query of the type “\textbf{C i j}” (\textbf{1} ≤ \textbf{i} ≤ \textbf{j} ≤ \textbf{n}). The corresponding line contains \textbf{4} integers; the number of points having indices in the range \[\textbf{i}..\textbf{j}\] in the \textbf{1}st, \textbf{2}nd, \textbf{3}rd and \textbf{4}th quadrants respectively.
Time limit 3 seconds
Memory limit 64 MiB
Input example #1
4
1 1
-1 1
-1 -1
1 -1
5
C 1 4
X 2 4
C 3 4
Y 1 2
C 1 3
Output example #1
1 1 1 1
1 1 0 0
0 2 0 1
Source Local Contest #1 Qafqaz University by Mahammad Valiyev