Problem Statement

We have n straight lines drawn in the Cartesian plane each described by two distinct points (x1[i], y1[i]) and (x2[i], y2[i]) lying on it. A center of symmetry is such a point that under a symmetry centered at this point the given configuration of lines goes into itself (i.e., the image of every given line under this symmetry is again one of the given lines). Return the number of centers of symmetry that the given system of lines has. Return -1 if there are infinitely many centers of symmetry.

Definition

Class:

CentersOfSymmetry

Method:

lineConfigurations

Parameters:

int[], int[], int[], int[]

Returns:

int

Method signature:

int lineConfigurations(int[] x1, int[] y1, int[] x2, int[] y2)

(be sure your method is public)

Notes

-

A symmetry centered at point X works as follows. The image of a point A is such a point B that X is the midpoint of the line segment AB (note that if A = X, then also B = X). The image of a line is the union of images of all points on this line.

Constraints

-

x1 will contain between 1 and 50 elements, inclusive.

-

x1, y1, x2, y2 will all contain the same number of elements.

-

All the elements of x1, y1, x2 and y2 will be between -50 and 50, inclusive.

-

For each i either x1[i] and x2[i] or y1[i] and y2[i] will be distinct (i.e., two points defining a line will be distinct).

-

All the lines defined by (x1[i], y1[i]) and (x2[i], y2[i]) will be distinct.

Examples

0)

{0, 0}

{0, 0}

{1, -1}

{1, 1}

Returns: 1

A configuration of two intersecting lines has a single center of symmetry - their intersection point.