Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

Re:WA;; Help~! (Please Reply in English!!)

Posted by ziliang at 2007-02-22 01:34:11 on Problem 1080
In Reply To:WA;; Help~! (Please Reply in English!!) Posted by:KysShadow at 2007-02-21 22:32:15
> 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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator