记搜WA&RE能过样例求大佬

P1140 相似基因

@[小闸蟹](/space/show?uid=59062) 大佬求带
by xiangling @ 2018-07-01 18:04:58


@constuctor
by xiangling @ 2018-07-01 18:11:23


@[constructor](/space/show?uid=56461)
by xiangling @ 2018-07-01 18:11:55


@[nothingness](/space/show?uid=31317)
by xiangling @ 2018-07-01 19:48:23


凉了
by xiangling @ 2018-07-01 20:16:02


更新的代码: ``` #include<iostream> #include<limits.h> #include<string> #define MAXN 1005 using namespace std; int a[MAXN],b[MAXN]; int F[MAXN][MAXN]; const int s[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,INT_MIN}; int f(int i,int j) { if(i==0||j==0)F[i][j]=0; else{ int temp1=f(i-1,j-1)+s[a[i]][b[j]]; int temp2=max(f(i-1,j)+s[a[i]][4],f(i,j-1)+s[b[j]][4]); F[i][j]=max(temp1,temp2); } return F[i][j]; } void transf(int A[],int len,const string st) { for(int i=0;i<len;i++) { if(st[i]=='A')A[i]=0; if(st[i]=='C')A[i]=1; if(st[i]=='G')A[i]=2; if(st[i]=='T')A[i]=3; } } /*============sample-input=========== 7 AGCTATT 9 AGCTTTAAA ================output=============== 21 */ int main() { int len1,len2; string s1,s2; cin>>len1>>s1; cin>>len2>>s2; transf(a,len1,s1); transf(b,len2,s2); cout<<f(len1,len2)<<endl; return 0; } ```
by xiangling @ 2018-07-01 20:35:34


明天考试,爱莫能助哇。。。@[rainman](/space/show?uid=55804)
by 小闸蟹 @ 2018-07-02 01:08:01


|