#abc219e. E - Moat
E - Moat
Score : points
问题描述
在 平面上有一些点,代表了一些村庄的位置。
高桥将要构建一条护城河来保护这些村庄免受敌人的侵袭,比如民间军队和女巫。
你得到一个由 和 组成的 矩阵 。
对于每一对整数 满足 且 ,坐标 处就有一个村庄。
护城河将在平面上形成一个多边形。高桥将按照以下条件来建造它。(参见示例输入/输出 1 的注释部分。)
- 没有自相交。
- 所有村庄都在多边形内部。
- 每个顶点的 和 坐标都是整数,范围在 到 (包含)之间。
- 每条边都与 轴或 轴平行。
- 每个内角为 度或 度。
请输出高桥构建护城河的不同方法数量。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
There are villages at some number of points in the -plane.
Takahashi will construct a moat to protect these villages from enemies such as civil armies and witches.
You are given a matrix consisting of and .
For each pair of integers such that , there is a village at the coordinates .
The moat will be a polygon in the plane. Takahashi will construct it so that the following conditions will be satisfied. (See also the annotation at Sample Input/Output 1.)
- There is no self-intersection.
- All villages are contained in the interior of the polygon.
- The - and -coordinates of every vertex are integers between and (inclusive).
- Every edge is parallel to the - or -axis.
- Every inner angle is or degrees.
Print the number of ways in which Takahashi can construct the moat.
Constraints
- There is at least one pair such that .
Input
Input is given from Standard Input in the following format:
Output
Print the number of ways in which Takahashi can construct the moat.
Sample Input 1
1 0 0 0
0 0 1 0
0 0 0 0
1 0 0 0
Sample Output 1
1272
The two ways to construct the moat shown in the images below are valid.
The four ways to construct the moat shown in the images below are invalid.
Here are the reasons the above ways are invalid.
- The first way violates the condition: "There is no self-intersection."
- The second way violates the condition: "All villages are contained in the interior of the polygon."
- The third way violates the condition: "The - and -coordinates of every vertex are integers between and ." (Some vertices have non-integer coordinates.)
- The fourth way violates the condition: "Every edge is parallel to the - or -axis."
Sample Input 2
1 1 1 1
1 1 1 1
1 1 1 1
1 1 1 1
Sample Output 2
1
update @ 2024/3/10 09:41:56