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 on test 7?
Posted by ss 12 Aug 2005 20:28
Here is my code:


type My=record
       den,ost,sez:longint;
     end;
     Matr=array[1..101,1..101] of longint;

var m,n,l,i,j,h,k,min,o,sum:longint;
    a: Matr;
    q: array[1..101] of longint;
    w: array[1..101] of my;
    f:boolean;

procedure floyd(var  c:matr);
var i,j,k:longint;
begin
  for k:=1 to n do
    for i:=1 to n do
      for j:=1 to n do
        if c[i,k]+c[k,j]<c[i,j] then c[i,j]:=c[i,k]+c[k,j];
  for i:=1 to n do c[i,i]:=0;
end;



begin
  readln(n,m);
  for i:=1 to n do
    for j:=1 to n do a[i,j]:= 1000000;
  for i:=1 to m do begin
    read(l);
    for j:=1 to l do read(q[j]);
    for j:=1 to l-1 do
      for h:=j+1 to l do begin
        a[q[j],q[h]]:=4;
        a[q[h],q[j]]:=4;
      end;
  end;
  floyd(a);
  readln(k);
  for i:=1 to k do readln(w[i].den,w[i].ost,w[i].sez);
  min:=1000000;
  for i:=1 to n do begin
  sum:=0;
    f:=true;
    for j:=1 to k do begin
      if w[j].sez=0 then
        if (w[j].den<a[i,w[j].ost]) then begin
          f:=false;
          break;
        end
        else sum:=sum+a[i,w[j].ost];
    end;

    if (f) and (min>sum) then begin
      o:=i;
      min:=sum;
    end;
  end;

  if min=1000000 then writeln(0)
  else writeln(o,' ',min);
end.
Re: Why WA on test 7?
Posted by Khramov Egor(9 class) 13 Aug 2005 19:15
Try this test:
4 2
2 1 2
2 3 4
2
0 1 1
0 3 1
Re: Why WA on test 7?
Posted by fallen 21 May 2009 00:29
Thx!
Re: Why WA on test 7?
Posted by wym510 25 Oct 2009 07:50
thanks
Re: Why WA on test 7?
Posted by yuanyuan 18 Feb 2010 12:28
thx very much!
Re: Why WA on test 7?
Posted by Phan Hoài Nam (HUFLIT) 7 Oct 2010 22:05
thank you very much !
I have got AC.
Re: Why WA on test 7?
Posted by Ade 8 May 2011 21:09
Thank you very much.

Seems it's a common mistake :)
Re: Why WA on test 7?
Posted by Eazy jobb 31 Jul 2011 13:21
Thx.39.
Re: Why WA on test 7?
Posted by Duwe 26 Sep 2012 14:26
THX! Very foolish mistake...