#P6679. [COCI 2019/2020 #2] Zvijezda

    ID: 7433 远端评测题 1000ms 128MiB 尝试: 0 已通过: 0 难度: 5 上传者: 标签>动态规划 DP2019树形 DPCOCI(克罗地亚)

[COCI 2019/2020 #2] Zvijezda

题目描述

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 NN. Slavko then considered each pair of oposite sides (two sides are opposite if there are N21\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 QQ 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?

输入格式

The first line contains an integer TT which is used as a parameter for generating Mirko's queries. This number can be either 00 or 11.

The second line contains an even integer NN from the task description.

Each of the next NN lines contains two integers Xi,YiX_i, Y_i (0Xi,Yi1090\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 QQ from the task description.

Each of the next QQ lines contains two integers Ai,BiA_i, B_i (0Ai,Bi210180\leq|A_i|,|B_i|\leq2\cdot10^{18}) which are used as parameters for generating the point in the ii - th of Mirko's queries.

Let XiX_i be equal to the number of points in the first ii (inclusive) of Mirko's queries that lie in the colored part of the plane. Naturally, X0=0X_0 = 0. The point of Mirko's ii - 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.

输出格式

The ii - th line of output should contain the word DA (YES in Croatian) if the point from ii - th of Mirko's queries lies in the colored part of the plane. Otherwise, the ii - th line should contain the word NE (NO in Croatian).

题目大意

Mirko 最近绘制了一个具有偶数个顶点 nn 的凸多边形。

Slavko 选出了每组对边(如果两个边之间有 n21\dfrac{n}{2}-1 边,则这两个边对边),画出位于这些边上的直线,并将它们与位于它们之间、包含多边形的平面部分一起涂上颜色。

最终,Mirko 选择了 qq 个点,并决定向 Slavko 询问,问他每个点是否位于有色或无色部分。

The Biggest Loser 节目即将开始,Slavko 没有时间回答 Mirko 的问题。你能帮她吗?

0
4
1 1
5 1
4 3
2 2
4
3 2
2 4
6 2
4 5

DA
NE
DA
NE
0
6
-1 -1
2 -1
3 3
2 4
1 4
-2 1
6
2 2
3 0
1 -6
2 6
-5 5
5 10

DA
DA
NE
NE
NE
NE
1
6
-1 -1
2 -1
3 3
2 4
1 4
-2 1
6
2 2
3 0
1 -6
2 6
-5 5
5 10

DA
DA
DA
NE
NE
NE

提示

数据规模及约定

本题采用捆绑测试。

Subtask Scores Constraints
11 2020 1n,q20001 \le n, q \le 2000T=0T = 0
22 3030 1n,q1051 \le n, q \le 10^5T=0T = 0
33 6060 1n,q1051 \le n, q \le 10^5T=1T = 1

此外,对于 100%100\% 的数据,$0 \le |x_i|, |y_i| \le 10^9, 0 \le |a_i|, |b_i| \le 2 \times 10^{18}$。

说明

本题分值按 COCI 原题设置,满分 110110

题目译自 COCI2019-2020 CONTEST #2 T5 Zvijezda