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

Why WA? 大牛请进! 我用的是Pascal

Posted by OIer_nk2008 at 2007-07-03 13:01:40 on Problem 1080
Program PKU_1080;
Const
  c: Array['1'..'5', '1'..'5'] Of Integer = ((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));
Var
  n, i, k, l1, l2, l: Integer;
  s1, s2, s: String;
  a: Array[1..111, 1..111] Of Longint;
Procedure Calc(x, y: Integer);
Var
  Max1, Max2: Longint;
Begin
  If (x = l1 + 1) Then Begin
    If (y = l2 + 1) Then Begin
      a[x, y] := 0;
      Exit;
    End Else Begin
      a[x, y] := -MaxInt;
      Exit;
    End;
  End;
  If (y > l2) Then Begin
      a[x, y] := -MaxInt;
      Exit;
  End;
  If (a[x + 1, y] = -1) Then Calc(x + 1, y);
  If (a[x + 1, y + 1] = -1) Then Calc(x + 1, y + 1);
  Max1 := a[x + 1, y] + c[s1[x], '5'];
  Max2 := a[x + 1, y + 1] + c[s1[x], s2[y]];
  If (Max1 > Max2) Then a[x, y] := Max1 Else a[x, y] := Max2;
End;
Begin
Assign(Input, 'Input.txt');
Reset(Input);
  Readln(n);
  For i:=1 To n Do Begin
    Read(l1);
    Readln(s1);
    Delete(s1, 1, 1);
    Delete(s1, l1 + 1, Length(s1) - l1);
    Fillchar(a, Sizeof(a), $FF);
    For l:=1 To l1 Do
      Case s1[l] Of
        'A': s1[l] := '1';
        'C': s1[l] := '2';
        'G': s1[l] := '3';
        'T': s1[l] := '4';
        ' ': s1[l] := '5';
      End;
    Read(l2);
    Readln(s2);
    Delete(s2, 1, 1);
    Delete(s2, l2 + 1, Length(s2) - l2);
    For l:=1 To l2 Do
      Case s2[l] Of
        'A': s2[l] := '1';
        'C': s2[l] := '2';
        'G': s2[l] := '3';
        'T': s2[l] := '4';
        ' ': s2[l] := '5';
      End;
    If (l1 < l2) Then Begin
      l := l1;
      l1 := l2;
      l2 := l;
      s := s1;
      s1 := s2;
      s2 := s;
    End;
    Calc(1, 1);
    Writeln(a[1, 1]);
  End;
Close(Input);
End.

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