BioScore
TCO04 Semifinal 1 · 2004-09-07 · by dgoodman
Problem Statement
Our problem is to construct the score matrix. It has the following restrictions:
- 1) All entries must be integers between -10 and 10 inclusive
- 2) It must be symmetric ( score(x,y) = score(y,x) )
- 3) Diagonal entries must be positive ( score(x,x)>0 )
- 4) The sum of the 16 entries must be 0.
Create a class BioScore that contains a method maxAvg that is given knownSet, the list of sequences known to be homologous. The method computes the optimum scoring matrix and returns the resulting maximal average homology score for the pairs from knownSet.
Constraints
- knownSet will contain between 2 and 50 elements inclusive
- each element of knownSet will contain only the uppercase letters A,C,T, and G.
- each element of knownSet will contain between 1 and 50 characters inclusive.
- all elements of knownSet will contain the same number of characters.
{"AAA","AAA","AAC"}
Returns: 30.0
Make score(A,A) and score(A,C) be 10. It is then easy to satisfy the remaining requirements. All three pairwise comparisons score 30.0.
{"ACTGACTGACTG","GACTTGACCTGA"}
Returns: -4.0
Here, there are no positions in which the letters in the two strings match each other. So we should give each exact match (each diagonal entry of the score matrix) the smallest possible score, 1. The remaining 12 pairs are each present at one position in the comparison so the best we can do is to choose those 12 scores so they add up to -4 in any manner. Now the sum of all the matrix entries is 0, and the resulting score for the one pairwise comparison is -4.
{"ACTAGAGAC","AAAAAAAAA","TAGTCATAC","GCAGCATTC"}
Returns: 50.5
{"TCGTCGTCGGCTCGT",
"GGGCTCGTCTTGTCT"}
Returns: 124.0
{"A","C","G","G","G","T"}
Returns: 4.6
Submissions are judged against all 25 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class BioScore with a public method double maxAvg(vector<string> knownSet) · 25 test cases · 2 s / 256 MB per case