QOJ.ac

QOJ

実行時間制限: 1 s メモリ制限: 256 MB 満点: 100

#3225. 贪吃蛇

統計

Snake 是一条由 $n$ 个顶点组成的折线(无自交)。初始时,Snake 的第 $i$ 个顶点的坐标为 $(x_i, y_i)$。Snake 可以通过平移和旋转进行连续运动,但其形状不能改变(折线中线段的长度和线段之间的夹角不能改变)。直线 $y = 0$ 是一堵墙,在 $(0, 0)$ 处有一个小孔。请确定 Snake 是否能穿过这个孔。(初始时,Snake 上的所有点均满足 $y > 0$。运动结束后,Snake 上的所有点均应满足 $y < 0$。)

输入格式

第一行包含一个整数 $n$ ($2 \le n \le 1000$)。接下来 $n$ 行,第 $i$ 行包含一对整数 $x_i$ 和 $y_i$ ($0 \le x_i \le 10^9, 1 \le y_i \le 10^9, (x_i, y_i) \neq (x_{i+1}, y_{i+1})$)。该折线没有自交,且任意三点不共线。

输出格式

如果 Snake 能穿过孔,输出 “Possible”。否则输出 “Impossible”。

样例

输入格式 1

4
0 1
1 1
1 2
2 2

输出格式 1

Possible

说明

对于第一个样例,解决方案可能如下所示:

  • 向 $-y$ 方向移动 1 个单位。
  • 绕点 $(0, 0)$ 逆时针旋转 90 度。
  • 向 $-y$ 方向移动 1 个单位。
  • 绕点 $(0, 0)$ 顺时针旋转 90 度。
  • 向 $-y$ 方向移动 1 个单位。
  • 绕点 $(0, 0)$ 逆时针旋转 90 度。
  • 向 $-y$ 方向移动 2 个单位。

输入格式 2

11
63 106
87 143
102 132
115 169
74 145
41 177
56 130
28 141
19 124
0 156
22 183

输出格式 2

Impossible

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.