ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1029. Ministry

Can you give me some test?
Posted by 复活_Angel 18 Feb 2006 18:18
var
  x1,x2,mink,minx,i,j,abcx:integer;
  n,m:integer;
  s,min,k:longint;
  num:array[0..500]of longint;
  costv:array[1..500]of longint;
  f:array[0..100,1..500]of longint;
  prec:array[1..100,1..500]of integer;
  wri:array[1..50000]of integer;
begin
  readln(n,m);
  fillchar(f,sizeof(f),0);
  for i:=1 to n do
    begin
      fillchar(num,sizeof(num),0);
      for j:=1 to m do read(costv[j]);
      for j:=1 to m do  num[j]:=num[j-1]+costv[j];
      for j:=1 to m do
        begin
          min:=maxlongint; mink:=j;
          for k:=1 to m do
            begin
              if j<k then s:=num[k]-num[j-1]+f[i-1,k]else
              s:=num[j]-num[k-1]+f[i-1,k];
              if s<min then begin min:=s; mink:=k;end;
            end;
          f[i,j]:=min; prec[i,j]:=mink;
        end;
      readln;
    end;
  min:=f[n,1];minx:=1;
  for i:=1 to m do
    begin
      if f[n,i]<min then begin min:=f[n,i];minx:=i;end;
    end;
  x1:=n;x2:=minx;
  k:=0;
  while x1<>0 do
     begin
       inc(k);
       wri[k]:=x2;
       if x2<>prec[x1,x2] then
         begin
           for abcx:=x2+1 to prec[x1,x2] do begin inc(k);wri[k]:=abcx;end;
           for abcx:=prec[x1,x2] to x2-1 do begin inc(k);wri[k]:=abcx;end;
         end;
       x2:=prec[x1,x2];   dec(x1);
     end;
     for i:=k downto 1 do writeln(wri[i]);
     close(input);
end.
I don't know why WA at Test 5.Who can give me some tests?