题目 20373

Zvijezda

查看题解 ↗GitHub ↗如何评测
题号
20373
时间限制
1000 ms
内存限制
256 MB
标签
比赛CSP-S
来源
CSP-S 国外模拟赛 23 - T3

第 3 题 Zvijezda (zvijezda)

CSP-S 复赛模拟赛 23 · 时间限制 1.0 s · 空间限制 256 MB · 30 个测试点 · 全文比较(过滤行末空格及文末回车)

本题使用文件输入输出:输入文件 zvijezda.in,输出文件 zvijezda.out。

题目描述

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 opposite sides (two sides are opposite if there are N2−1\frac{N}{2} - 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 0 or 1.

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

Each of the next NN lines contains two integers XiX_i, YiY_i (0≤∣Xi∣,∣Yi∣≤1090 \le |X_i|, |Y_i| \le 10^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 AiA_i, BiB_i (0≤∣Ai∣,∣Bi∣≤2⋅10180 \le |A_i|, |B_i| \le 2 \cdot 10^{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:

Pi=(Ai⊕(T⋅Xi−13),Bi⊕(T⋅Xi−13))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).

样例

样例 1

输入:

文本
0
4
1 1
5 1
4 3
2 2
4
3 2
2 4
6 2
4 5

输出:

文本
DA
NE
DA
NE

样例 2

输入:

文本
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

样例 3

输入:

文本
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
1 20 1≤n,q≤20001 \le n, q \le 2000,T=0T = 0
2 30 1≤n,q≤1051 \le n, q \le 10^5,T=0T = 0
3 60 1≤n,q≤1051 \le n, q \le 10^5,T=1T = 1

此外,对于 100% 的数据,0≤∣xi∣,∣yi∣≤1090 \le |x_i|, |y_i| \le 10^9,0≤∣ai∣,∣bi∣≤2×10180 \le |a_i|, |b_i| \le 2 \times 10^{18}。

说明

**

**

数据下载

题目 20373 的公开数据

正在读取文件列表…

常用命令

题目 20373 的 ROJ 命令

以下命令默认使用全局安装的 ROJ Skill,请在终端中直接执行;如果修改过 AGENT_HOME,请将命令中的 ~/.agents 替换为对应目录。