시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
12 초 (추가 시간 없음) | 1024 MB | 3 | 0 | 0 | 0.000% |
This problem might be well-known in some countries, but how do other countries learn about such problems if nobody poses them.
There are $n$ points on the plane, where the $i$-th point $(x_i,y_i)$ has value $\mathbf d_i \in D$. Two sets $D$ and $O$ are given, with the following properties:
In this problem, we treat $D$ as the set of all $3 \times 1$ matrices over $\mathbb F_{p}$ and $O$ as the set of all $3 \times 3$ matrices over $\mathbb F_{p}$, where $p = 10^9+7$. That is, you can treat the above operations as the usual matrix addition and matrix multiplication modulo $10^9+7$.
Now, $m$ queries are given in the form a b c o
:
As a data structure master, you need to perform all queries and find the answer.
The first line of the input contains a single integer $n$ ($1 \le n \le 3 \cdot 10^5$), indicating the number of points.
Each of the following $n$ lines contains five integers $x_i, y_i, d_{i0}, d_{i1}, d_{i2}$, indicating the coordinates of the $i$-th point and its value $\mathbf d_i = \left[\begin{matrix}d_{i0}\\d_{i1}\\d_{i2}\end{matrix}\right]$.
The next line of the input contains a single integer $m$ ($1 \le m \le 1.5 \cdot 10^4$), indicating the number of the queries.
Each of the following $m$ lines contains twelve integers $a, b, c, {o}_{00}, {o}_{01}, {o}_{02}, {o}_{10}, \ldots, {o}_{22}$. Note that the real $\mathbf o = \left[\begin{matrix} o_{00} & o_{01} & o_{02} \\ o_{10} & o_{11} & o_{12}\\ o_{20} & o_{21} & o_{22}\end{matrix}\right]$.
It is guaranteed that:
For each query, output a single line containing three integers $s_0, s_1, s_2$, indicating $\mathbf s = \left[\begin{matrix}s_{0}\\s_{1}\\s_{2}\end{matrix}\right]$.
5 1 1 2 3 4 12 12 4 6 1 1 12 5 1 2 12 1 1 5 5 6 6 2 0 3 3 1 1 4 1 1 2 3 4 5 2 3 4 1 1 400 1 3 4 2 1 2 3 4 5 -1 -1 -10 3 2 1 4 6 5 4 3 2
2 3 4 25 50 40 92 58 139
Note that the solution does not depend on other properties of matrix addition/multiplication than those mentioned in the statements. Defining $D$ and $O$ as sets of matrices is only for testing convenience (since we can't use the graders or interaction libraries).