#K46782. Minimum Energy Cost for DNA Transformation
Minimum Energy Cost for DNA Transformation
Minimum Energy Cost for DNA Transformation
You are given two DNA sequences: an initial sequence and a target sequence. In addition, you are provided with a 4×4 cost matrix \(C\) where each element \(C_{ij}\) represents the energy cost to transform the nucleotide corresponding to index \(i\) to the nucleotide corresponding to index \(j\). The nucleotides are mapped as follows:
- A \(\rightarrow 0\)
- C \(\rightarrow 1\)
- G \(\rightarrow 2\)
- T \(\rightarrow 3\)
Your task is to compute the total minimum energy cost required to transform the initial sequence into the target sequence by converting each nucleotide individually.
inputFormat
The input is read from standard input (stdin) and consists of 6 lines:
- The first line contains the initial DNA sequence.
- The second line contains the target DNA sequence.
- The next four lines each contain four space-separated integers representing a row of the cost matrix \(C\).
outputFormat
Output a single integer to standard output (stdout), which is the minimum energy cost to transform the initial sequence into the target sequence.
## sampleACGT
TGCA
0 1 2 3
1 0 2 3
1 2 0 3
1 2 3 0
8