比赛 |
20090715 |
评测结果 |
AAAAAAAAAA |
题目名称 |
相似基因 |
最终得分 |
100 |
用户昵称 |
cqw |
运行时间 |
0.000 s |
代码语言 |
Pascal |
内存使用 |
0.00 MiB |
提交时间 |
2009-07-15 11:26:53 |
显示代码纯文本
const p:string='ACGT';
a:array[0..4,0..4] of integer=((0,-3,-4,-2,-1),
(-3,5,-1,-2,-1),
(-4,-1,5,-3,-2),
(-2,-2,-3,5,-2),
(-1,-1,-2,-2,5));
var
s1,s2:string;
b:array[0..100,0..100] of integer;
l1,l2,i,j,k:integer;
begin
assign(input,'gene.in');
reset(input);
readln(s1);
readln(s2);
close(input);
k:=pos(' ',s1);
s1:=copy(s1,k+1,100);
l1:=length(s1);
k:=pos(' ',s2);
s2:=copy(s2,k+1,100);
l2:=length(s2);
b[0,0]:=0;
for i:=1 to l1 do b[0,i]:=b[0,i-1]+a[0,pos(s1[i],p)];
for i:=1 to l2 do b[i,0]:=b[i-1,0]+a[pos(s2[i],p),0];
for i:=1 to l2 do
for j:=1 to l1 do
begin
if b[i,j-1]+a[0,pos(s1[j],p)]>b[i-1,j]+a[pos(s2[i],p),0]
then b[i,j]:=b[i,j-1]+a[0,pos(s1[j],p)]
else b[i,j]:=b[i-1,j]+a[pos(s2[i],p),0];
if b[i,j]<b[i-1,j-1]+a[pos(s2[i],p),pos(s1[j],p)] then
b[i,j]:=b[i-1,j-1]+a[pos(s2[i],p),pos(s1[j],p)]
end;
assign(output,'gene.out');
rewrite(output);
writeln(b[l2,l1]);
close(output);
end.