#P7101. Sum of Triangle Area Eighth Powers
Sum of Triangle Area Eighth Powers
Sum of Triangle Area Eighth Powers
You are given an initially empty set of points in the plane. There are N operations. In each operation, a point is inserted into or removed from the set. After each operation, you must compute the following:
If the current set of points is S, consider every triple of distinct points from S that forms a triangle. Let the area of a triangle with vertices \((x_1,y_1)\), \((x_2,y_2)\), and \((x_3,y_3)\) be defined as
[ A = \frac{|x_1(y_2-y_3) + x_2(y_3-y_1) + x_3(y_1-y_2)|}{2}, ]
For each triangle, take the 8th power of its area, i.e., \(A^8\), and compute the sum over all triangles. Since \(A^8 = \frac{|\text{cross}|^8}{256}\) (where \(|\text{cross}|\) is the absolute value of the triangle's doubled area), the answer can be written as a rational number \(a/b\) in lowest terms.
You are to output the value \(a \cdot b^{-1} \pmod{998244353}\), where \(b^{-1}\) is the modular inverse of \(b\) modulo 998244353
.
inputFormat
The first line contains an integer N, the number of operations. Each of the following N lines contains an operation in one of the following formats:
+ x y
: Insert the point \((x,y)\) into the set.- x y
: Remove one occurrence of the point \((x,y)\) from the set.
After each operation, you must output the answer described above.
outputFormat
Output N lines. The i-th line should contain the answer after performing the first i operations. Each answer is computed as \(a \cdot b^{-1} \pmod{998244353}\) as explained in the problem statement.
sample
3
+ 0 0
+ 1 0
+ 0 1
994344961
</p>