cho.sh
Notes
Loading...

DNA Score

Time limit

2s

Memory limit

128 MB

Problem

A DNA string is a string consisting only of A, C, T, and G. For two DNA strings X and Y of the same length, their DNA score is the sum of Score(X_i, Y_i) over every position i. Score is a 4 by 4 integer score table whose rows and columns are the four DNA characters.

The score table must satisfy all of the following rules.

  1. Every entry is an integer between -10 and 10, inclusive.
  2. The table is symmetric across its main diagonal: Score(X, Y) = Score(Y, X).
  3. Every diagonal entry is positive: Score(X, X) > 0.
  4. The sum of all 16 entries in the table is 0.

You are given N DNA strings of equal length. Choose a score table that maximizes the average DNA score over all N(N-1)/2 unordered pairs of distinct strings, and output that maximum average.

Input

The first line contains the number of DNA strings N, where N is a positive integer not greater than 50.

Each of the next N lines contains one DNA string. All strings have the same length, and the maximum length is 50.

Output

Output the maximum possible average DNA score. Answers with absolute or relative error at most 10^-2 are accepted.

Hint

In the first public test, Score(A, A) and Score(A, C) can both be set to 10. The remaining entries can then be chosen to satisfy the rules, so each of the three string-pair scores is 30.