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

I got WA, please help me! Give some test!
Posted by Algorithmus_UA(algorithmus@univ.kiev.ua) 14 Oct 2002 22:42
var N,M,i,j,k,gl,l:integer;
    a:array[1..100,1..100]of integer;
    z,s,c,b:array[1..100]of longint;
    gmin,sum:longint;
    suxx:boolean;
begin
{  assign(input,'1085.dat');reset(input);}
  readln(N,M);
  for i:=1 to N do for j:=1 to N do a[i,j]:=10000;
  for i:=1 to N do a[i,i]:=0;
  for i:=1 to M do
  begin
    read(K);
    for j:=1 to K do read(z[j]);
    for j:=1 to K do for l:=j+1 to K do begin a[z[j],z[l]]:=1;a[z[l],z
[j]]:=1;end;
  end;
  read(K);for i:=1 to K do read(s[i],c[i],b[i]);
  for k:=1 to N do
   for i:=1 to N do
    for j:=1 to N do if a[i,k]+a[k,j]<a[i,j] then a[i,j]:=a[i,k]+a
[k,j];
  gmin:=MaxInt;
  for i:=1 to N do
  begin
    sum:=0;suxx:=false;
    for j:=1 to N do if (b[j] = 0) then
    begin
      if a[c[j],i]*4>s[j] then
      begin
        suxx:=true;
        break;
      end;
      sum:=sum+a[c[j],i]*4;
    end;
    if not suxx then
    begin
      if sum<gmin then begin gmin:=sum;gl:=i;end;
    end;
  end;
  if gmin = maxint then writeln(0) else writeln(gl,' ',gmin);
end.
Sorry, I was find bug and got AC!
Posted by Algorithmus_UA(algorithmus@univ.kiev.ua) 15 Oct 2002 14:02