P6679 [COCI 2019/2020 #2] Zvijezda
Description
Mirko and Slavko are spending their free time playing with polygons and watching a new season of *The Biggest Loser*. Mirko recently drew a convex polygon with an even number of vertices $N$. Slavko then considered each pair of oposite sides (two sides are opposite if there are $\dfrac N2 - 1$ sides between them), drew straight lines that lie on those sides and colored them along with the part of the plane that lies between them and contains the polygon. Finally, Mirko found a set of $Q $ points and decided to challenge Slavko to answer for each point whether it lies in the colored or uncolored part of the plane. The new episode of *The Biggest Loser* is about to start and Slavko doesn’t have the time to answer Mirko’s queries. Can you help him?
Input Format
The first line contains an integer $T$ which is used as a parameter for generating Mirko's queries. This number can be either $0$ or $1$.
The second line contains an even integer $N$ from the task description.
Each of the next $N$ lines contains two integers $X_i, Y_i$ ($0\leq|X_i|,|Y_i|\leq10^9$) which represent one of the polygon's vertices. You can assume that the vertices are given in the counter - clockwise order and that no three successive vertices are collinear.
The next line contains an integer $Q$ from the task description.
Each of the next $Q$ lines contains two integers $A_i, B_i$ ($0\leq|A_i|,|B_i|\leq2\cdot10^{18}$) which are used as parameters for generating the point in the $i$ - th of Mirko's queries.
Let $X_i$ be equal to the number of points in the first $i$ (inclusive) of Mirko's queries that lie in the colored part of the plane. Naturally, $X_0 = 0$. The point of Mirko's $i$ - th query should then be generated as:
$$
P_i=(A_i\oplus(T\cdot X_{i - 1}^3),B_i\oplus(T\cdot X_{i - 1}^3))
$$
where $\oplus$ represents the bitwise xor operation.
Output Format
The $i$ - th line of output should contain the word `DA` (YES in Croatian) if the point from $i$ - th of Mirko's queries lies in the colored part of the plane. Otherwise, the $i$ - th line should contain the word `NE` (NO in Croatian).
Explanation/Hint
#### 数据规模及约定
本题采用捆绑测试。
| Subtask | Scores | Constraints |
| :-----------: | :-----------: | :-----------: |
| $1$ | $20$ | $1 \le n, q \le 2000$,$T = 0$|
| $2$ | $30$ | $1 \le n, q \le 10^5$,$T = 0$|
| $3$ | $60$ | $1 \le n, q \le 10^5$,$T = 1$|。
此外,对于 $100\%$ 的数据,$0 \le |x_i|, |y_i| \le 10^9, 0 \le |a_i|, |b_i| \le 2 \times 10^{18}$。
#### 说明
**本题分值按 COCI 原题设置,满分 $110$。**
**题目译自 [COCI2019-2020](https://hsin.hr/coci/archive/2019_2020/) [CONTEST #2](https://hsin.hr/coci/archive/2019_2020/contest2_tasks.pdf) *T5 Zvijezda*。**