Half the Polygon

An orthogonal polygon has the property that all of its edge intersections are at right angles. Thus the interior angle at each vertex is either 90°or 270°. Given an orthogonal simple polygon (non-self intersecting or touching) with integer coordinates, determine if it can be cut exactly in half with a horizontal or vertical segment, such that we end up dividing the polygon into two identical polygons. Two polygons are considered identical if one can be transformed into the other using some combination of reflections, rotations and translations. Also, the endpoints of the dividing segment must also be integers. Input A number of of inputs (≤ 50), each starting with one integer n (4 ≤ n ≤ 100000) on a line, the number vertices in the polygon. This is followed by n lines, each with the x, y (0 ≤ x,y ≤ 109) coordinates indicating a vertex on the polygon (listed in order, such that connecting them in order yields the polygon). Output For each input, output ‘Yes’, if the polygon can be split in half with a, vertical or horizontal, cut and ‘No’ otherwise. Sample Input 4 02 22 20 00 6 00 10 11 21 22 02 Sample Output Yes No