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,实在不知道哪里错了。。。

Posted by 674396380 at 2011-08-29 15:13:44 on Problem 1080
In Reply To:那位高手、牛人帮忙看看,为什么总是WA,实在不知道哪里错了。。。 Posted by:gdcc11 at 2009-05-02 19:24:58
> #include<stdio.h>
> #include<string.h>
> int sf(char a,char b)
> {
> 	if(a==b) return 5;
> 	if((a=='A'&&b=='C')||(a=='C'&&b=='A')) return -1;
> 	if((a=='A'&&b=='G')||(a=='G'&&b=='A')) return -2;
> 	if((a=='A'&&b=='T')||(a=='T'&&b=='A')) return -1;
> 	if((a=='A'&&b=='-')||(a=='-'&&b=='A')) return -3;
> 	if((a=='C'&&b=='G')||(a=='G'&&b=='C')) return -3; 
> 	if((a=='C'&&b=='T')||(a=='T'&&b=='C')) return -2;
> 	if((a=='C'&&b=='-')||(a=='-'&&b=='C')) return -4;
> 	if((a=='G'&&b=='T')||(a=='T'&&b=='G')) return -2;
> 	if((a=='G'&&b=='-')||(a=='-'&&b=='G')) return -2;
> 	if((a=='T'&&b=='-')||(a=='-'&&b=='T')) return -1;
> }
> int max(int i,int j,int k)
> {
> 	if(i>j)
> 		j = i;
> 	if(j>k)
> 		k = j;
> 	return k;
> }
> int main()
> {
> 	int t;
> 	scanf("%d",&t);
> 	char a[105],b[105];
> 	int la,lb;
> 	int sc[105][105];
> 	int i,j;
> 	while(t--){
> 		memset(sc,0,sizeof(sc));
> 		scanf("%d %s",&la,a);
> 		scanf("%d %s",&lb,b);
> 		sc[0][0] = 0;
> 		for(i=1;i<=la;i++)
> 			sc[i][0] = sf(a[i-1],'-');	
> 		for(i=1;i<=lb;i++)
> 			sc[0][i] = sf(b[i-1],'-');
> 
> 		for(i=1;i<=la;i++){
> 			for(j=1;j<=lb;j++){
> 				sc[i][j] = max( sc[i-1][j]+sf(a[i-1],'-'),sc[i][j-1]+sf('-',b[j-1]),sc[i-1][j-1]+sf(b[j-1],a[i-1]) );
> 			}
> 		}
> 		printf("%d\n",sc[la][lb]);
> 	}
> 	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