| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
WA;; Help~! (Please Reply in English!!)What's Wrong??
I can't find it;;
=====================================================
#pragma warning (disable : 4786)
#include <iostream>
#include <string>
#include <map>
using namespace std;
void init();
void input();
void proc();
int max(int t1, int t2, int t3);
int Max(int t1, int t2);
int Min(int t1, int t2);
map<char, int> char2int;
int len1, len2, a[101][101] = {0}, point[6][6];
string gene1, gene2;
int main() {
init();
input();
return 0;
}
void init() {
char2int['A'] = 1;
char2int['C'] = 2;
char2int['G'] = 3;
char2int['T'] = 4;
char2int['-'] = 5;
point[1][1] = 5;
point[1][2] = -1;
point[1][3] = -2;
point[1][4] = -1;
point[1][5] = -3;
point[2][2] = 5;
point[2][3] = -3;
point[2][4] = -2;
point[2][5] = -4;
point[3][3] = 5;
point[3][4] = -2;
point[3][5] = -2;
point[4][4] = 5;
point[4][5] = -1;
}
void input() {
int n, i, temp1;
string temp2;
cin >> n;
for(i = 1; i <= n; i++) {
cin >> len1 >> gene1;
cin >> len2 >> gene2;
if(len1 < len2) {
temp1 = len1;
len1 = len2;
len2 = temp1;
temp2 = gene1;
gene1 = gene2;
gene2 = temp2;
}
proc();
cout << a[len1][len2] << endl;
}
}
void proc() {
int i, j;
for(i = 1; i <= Max(len1, len2); i++)
a[i][0] = a[0][i] = -2100000000;
a[0][0] = 0;
for(i = 1; i <= len1; i++) {
for(j = 1; j <= len2; j++) {
a[i][j] = max(a[i - 1][j] + point[char2int[gene1[i - 1]]][char2int['-']],
a[i][j - 1] + point[char2int[gene2[j - 1]]][char2int['-']],
a[i - 1][j - 1] + point[Min(char2int[gene1[i - 1]], char2int[gene2[j - 1]])][Max(char2int[gene1[i - 1]], char2int[gene2[j - 1]])]);
}
}
}
int max(int t1, int t2, int t3) {
int t = t1;
if(t < t2) t = t2;
if(t < t3) t = t3;
return t;
}
int Max(int t1, int t2) {
if(t1 > t2)
return t1;
return t2;
}
int Min(int t1, int t2) {
if(t1 < t2)
return t1;
return t2;
}
=========================================================
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator