Universal Cup Judging System

Universal Cup

Limite de temps : 3 s Limite de mémoire : 2048 MB Points totaux : 100
Statistiques

简单多边形是指一个不自交且不含任何孔洞的多边形。给定一个简单多边形的 $N$ 个顶点 $v_1, v_2, \dots, v_N$,其中 $v_i = (x_i, y_i)$,$x_i$ 和 $y_i$ 分别是第 $i$ 个顶点的 $x$ 坐标和 $y$ 坐标。顶点互不相同,并按逆时针顺序给出(因此每对相邻顶点之间有一条边;从 $v_N$ 到 $v_1$ 之间也有一条边)。

多边形的边界不经过任何格点(格点是指两个坐标均为整数的点)。此外,$x_i$ 或 $y_i$ 的值均不为整数。

半整数点是指恰好有一个坐标为整数的点。令 $\mathcal{P} = \{p_1, p_2, \dots, p_k\}$ 为多边形边界上所有的半整数点。对于 $\mathcal{P}$ 中的每个半整数点 $p_i$,令 $n_i$ 为 $p_i$ 的非整数坐标的向下取整值。对于 $\mathcal{P}$ 的一个子集 $S$,令 $\sigma(S)$ 为 $S$ 中所有点的 $n_i$ 之和(规定 $\sigma(\emptyset) = 0$)。是否存在一种将 $\mathcal{P}$ 分割为两个子集 $S_1$ 和 $S_2$ 的方案,使得 $\sigma(S_1) = \sigma(S_2)$?

(如果 $\mathcal{P} = S_1 \cup S_2$ 且 $S_1 \cap S_2 = \emptyset$,则称两个集合 $S_1$ 和 $S_2$ 为 $\mathcal{P}$ 的一个分割。只要满足这两个条件且 $\sigma(S_1) = \sigma(S_2)$,对 $S_1$ 和 $S_2$ 没有其他限制。特别地,允许空集,且每个集合中的半整数点不需要在多边形边界上连续。)

输入格式

输入的第一行包含一个整数 $N$ ($3 \le N \le 500$),表示多边形的顶点数。

接下来的 $N$ 行,每行包含两个空格分隔的实数 $x_i$ 和 $y_i$ ($-500 < x_i, y_i < 500$):表示多边形顶点的坐标,按逆时针顺序给出。每个坐标小数点后恰好有 6 位数字,且不为整数。

保证多边形不自交,顶点互不相同,且多边形边界不经过任何格点。

输出格式

如果不存在解,输出 $-1$ 且不再输出其他内容。

否则,输出一行一个整数 $M$:表示有效分割中其中一个子集所包含的半整数点的数量。在接下来的 $M$ 行中,每行输出该子集中点的 $n_i$ 值。

如果存在多个有效分割,你可以选择其中任意一个。你可以输出两个子集中的任意一个,且子集中的 $n_i$ 值可以以任意顺序排列。

样例

样例输入 1

4
-0.950000 -0.850000
-0.100000 0.999999
0.111000 0.555000
-0.200000 1.600000

样例输出 1

3
0
-1
-1

说明

样例输入 1 如下图所示:

顶点标记为 $A, B, C, D$。半整数点用橙色标记,并从 $A$ 开始按逆时针方向沿周长标记为 $p_i$。按相同顺序,半整数点的 $n_i$ 值为 $-1, 0, 0, -1, -1, -1$。任何和为 $-2$ 的值子集均被视为正确。样例输出 1 展示了一种可能的正确答案。

样例输入 2 中的多边形边界不与任何半整数点相交,因此 $\mathcal{P}$ 为空集,它可以被分割为两个空集,每个集合的 $n_i$ 之和均为零。

样例输入 2

3
0.500000 0.700000
0.100000 0.200000
0.800000 0.900000

样例输出 2

0

样例输入 3

4
-360.000001 -24.000001
-359.999999 -24.000001
-359.999999 -23.999999
-360.000001 -23.999999

样例输出 3

2
-25
-360

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.