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

哭了,把各个关系对应的数据输错了,一直Wrong Answer 哭了

Posted by zhongdi at 2012-07-16 17:39:35 on Problem 1080
表示换了3个方法,唉,后来突然发现关系数据错了。。。。。
好了,贴个代码
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
char str1[1005];
char str2[1005];
int gene[1005][1005];
char map[2000];
int main()
{
	
	map['A']=0;  map['C']=1;  map['G']=2;  map['T']=3;  map['-']=4;
	int score[5][5]={{5,-1,-2,-1,-3},{-1,5,-3,-2,-4},{-2,-3,5,-2,-2},{-1,-2,-2,5,-1},{-3,-4,-2,-1,0}};
	int t,x,y;
	cin>>t;
	while(t--)
	{
		scanf("%d%s",&x,str1);
		scanf("%d%s",&y,str2);
		gene[0][0]=0;
		for(int i=1;i<=x;i++)
			gene[0][i]=gene[0][i-1]+score[map[str1[i-1]]][4];
		for(int i=1;i<=y;i++)
			gene[i][0]=gene[i-1][0]+score[4][map[str2[i-1]]];
		int m1,m2,m3;
		for(int i=1;i<=y;i++)
		{
			for(int j=1;j<=x;j++)
			{
				m1=gene[i-1][j]+score[4][map[str2[i-1]]];
				m2=gene[i][j-1]+score[map[str1[j-1]]][4];
				m3=gene[i-1][j-1]+score[map[str2[i-1]]][map[str1[j-1]]];
				gene[i][j]=max(max(m1,m2),max(m2,m3));
			}
		}
		cout<<gene[y][x]<<endl;
	}
	return 0;
}

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