#K71102. Symmetric Garden
Symmetric Garden
Symmetric Garden
You are given a polygon with n vertices. The polygon represents a garden. Determine whether the garden can be divided into two identical halves by a straight line passing through the origin.
The polygon is said to be symmetric if for every vertex with coordinates \((x_i, y_i)\), there exists another vertex \((x_j, y_j)\) such that:
\(x_i + x_j = 0\) and \(y_i + y_j = 0\).
Note that if \(n\) is odd, symmetry is impossible. Your task is to print YES
if the garden is symmetric according to the condition above, or NO
otherwise.
inputFormat
The input is read from stdin
and has the following format:
- The first line contains a single integer \(n\) (the number of vertices).
- Each of the next \(n\) lines contains two space-separated integers \(x\) and \(y\) representing the coordinates of a vertex.
outputFormat
Output a single line to stdout
containing YES
if the garden is symmetric, or NO
otherwise.
4
1 1
-1 1
-1 -1
1 -1
YES