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

这个题怎么听人说用floyed?

Posted by yoyosir at 2006-10-05 17:32:59 on Problem 2241
我用的最长非降子序列
WA了
谁能讲讲啊?
我的程序
var
  s:array[0..90,1..3]of longint;
  f:array[1..90]of longint;
  i,j,k,n,max:longint;
procedure swap(var x,y:longint);
var
  t:longint;
begin
  t:=x;
  x:=y;
  y:=t;
end;
begin
  readln(n);
  while n>0 do
  begin
    fillchar(s,sizeof(s),0);
    fillchar(f,sizeof(f),0);
    for i:=1 to n do
    begin
      for j:=1 to 3 do
        read(s[3*i-2,j]);
      readln;
      for k:=1 downto 0 do
      begin
        for j:=1 to 2 do
          s[3*i-k,j]:=s[3*i-k-1,j+1];
        s[3*i-k,3]:=s[3*i-k-1,1];
      end;
    end;
    for i:=1 to 3 do
      s[0,i]:=0;
    for i:=1 to 3*n do
    begin
      max:=i;
      for j:=i+1 to 3*n do
        if (s[max,1]<s[j,1])and(s[max,2]<s[j,2]) or (s[max,2]<s[j,1])and(s[max,1]<s[j,2])
          then max:=j;
      if max>i then
      begin
        swap(s[max,1],s[i,1]);
        swap(s[max,2],s[i,2]);
        swap(s[max,3],s[i,3]);
      end;
    end;
    for i:=1 to 3*n do
      f[i]:=s[i,3];
    for i:=2 to 3*n do
      for j:=1 to i-1 do
        if  ((s[i,1]<s[j,1])and(s[i,2]<s[j,2]) or (s[i,2]<s[j,1])and(s[i,1]<s[j,2]))and(f[j]+s[i,3]>f[i]) then f[i]:=f[j]+s[i,3];
    max:=0;
    for i:=1 to 3*n do
      if max<f[i] then max:=f[i];
    writeln(max);
    readln(n);
  end;
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