PROBLEM STATEMENT

A skew symmetric matrix M satisfies MT = -M, where MT denotes the transpose of the matrix M and -M denotes the matrix obtained by multiplying each entry of M by -1. The transpose of a matrix M is obtained by replacing the element in the i'th row and j'th column of M with the element in the j'th row and i'th column of M. Note that this requires the diagonal elements of a skew-symmetric matrix to be equal to 0. Create a class SkewSymmetric which contains a method minChanges. The method will take a vector <string> M, each element of which is a single space separated list of integers. The j'th number in the i'th element of M represents the value at row i and column j of the matrix. The method should return the minimum number of values in M that must be changed such that the resulting matrix is skew symmetric.

Definition

Class: SkewSymmetric
Method: minChanges
Parameters: vector <string>
Returns: int
Method signature:int minChanges(vector <string> M)

Constraints

Examples

Example 1:

{"1 2 8", "-2 1 0", "3 99 3"}
Returns: 5

One possible skew-symmetric matrix obtained by changing 5 elements in M is:

  0  2  -3
 -2  0 -99
  3 99   0
Note that the diagonal elements must be 0.

Example 2

{"0 1 1 1 1 1", "-1 0 1 1 1 1", "-1 -1 0 1 1 1", 
"-1 -1 -1 0 1 1", "-1 -1 -1 -1 0 1", "0 0 0 0 0 0"}
Returns: 5

Example 3:

{"0 0 0 0", "0 0 0 0", "0 0 0 0", "0 0 0 0"}
Returns: 0

Example 4:

{"1 0", "0 1"}
Returns: 2