atcoder#ABC219E. [ABC219E] Moat
[ABC219E] Moat
Score : points
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.
1 0 0 0
0 0 1 0
0 0 0 0
1 0 0 0
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."
1 1 1 1
1 1 1 1
1 1 1 1
1 1 1 1
1