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 1085. Meeting

Why WA. Please, help!!!
Posted by AIT 7 Dec 2002 18:08
This is my program. What's wrong with it?

type tchel = record start: byte; money: word; pr: byte; end;
Var n, m, k, kk: longint;
    mas: array [1..100,1..100] of integer;
    guys: array [1..100] of tchel;
    tm: array [1..100] of byte;
    i, j, h, l: longint;
    baki, bt: longint;
    nom: longint;
    can: boolean;
function min (a, b: longint): longint;
begin
     if a<b then min:=a else min:=b;
end;
Begin
    read(n, m);
    for i:=1 to n do
     for j:=1 to n do
     mas[i,j]:=10000;
    for i:=1 to m do
    begin
         read(h);
         for j:=1 to h do
         read(tm[j]);
         for j:=1 to h do
          for l:=1 to h do
          if l<>j then
          mas[tm[j],tm[l]]:=1;
    end;
    read(k);
    for i:=1 to k do
    begin
         read(guys[i].money,guys[i].start,guys[i].pr);
    end;
    baki:= maxlongint;
    for kK:=1 to n do
     for i:=1 to n do
      for j:=1 to n do
      mas[i,j]:=min(mas[i,j],mas[i,kk]+mas[kk,j]);
      for i:=1 to n do
       mas[i,i]:=0;
      for i:=1 to n do
      begin
           can:=true;
           bt:=0;
           for j:=1 to k do
           begin
                h:=mas[guys[j].start,i];
                h:=h*4;
                if (h<=guys[j].money)or(guys[j].pr=1) then
                begin
                     if guys[j].pr = 0 then
                     inc(bt,h);
                end
                else
                begin
                     can:=false;
                     break;
                end;
           end;
           if can then if bt<baki then begin baki:=bt; nom:=i; end;
      end;
      if baki = maxlongint then
      writeln(0)
      else
      begin
           writeln(nom,' ', baki);
      end;
End.