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 1109. Conference

Why I get WA? Pelase, help me!!!!!!! (+)
Posted by Nazarov Denis (nsc2001@rambler.ru) 12 Jan 2002 16:10
My program:

Program t1109;

Const MaxN=1000;
      MaxK=500000;

Var   A,B     :array[1..MaxN]of integer;
      AU,BU   :array[1..MaxN]of integer;
      Ver     :array[1..MaxK,1..2]of integer;
      M,N,K,i :integer;
      Mi,Ni   :integer;
      Ans     :integer;

begin
 FillChar(A,SizeOf(A),0);
 FillChar(B,SizeOf(B),0);
 FillChar(AU,SizeOf(AU),0);
 FillChar(BU,SizeOf(BU),0);
 Read(M,N,K);
 for i:=1 to K do begin
   read(ver[i,1],ver[i,2]);
   inc(a[ver[i,1]]);
   inc(b[ver[i,2]]);
  end;
 Ans:=0;
 Ni:=N;
 Mi:=M;
 for i:=1 to K do
  if a[ver[i,1]]=1 then begin
   Ans:=Ans+1;
   if BU[ver[i,2]]=0 then dec(Mi);
   BU[ver[i,2]]:=1;
   dec(Ni);
  end;
 for i:=1 to K do
  if b[ver[i,2]]=1 then
   if BU[ver[i,2]]=0 then begin
    Ans:=Ans+1;
    if AU[ver[i,1]]=0 then dec(Ni);
    AU[ver[i,1]]:=1;
    dec(Mi);
   end;
 Ans:=Ans+Mi+Ni;
 Writeln(Ans);
end.
Re:I find some errors but I still get WA. Pelase, help me!!!!!!! (+)
Posted by Nazarov Denis (nsc2001@rambler.ru) 12 Jan 2002 19:52
My program:

Program t1109;

Const MaxN=1000;
      MaxK=500000;

Var   A,B       :array[1..MaxN]of integer;
      AU,BU     :array[1..MaxN]of integer;
      Ver       :array[1..MaxK,1..2]of integer;
      M,N,K,i   :integer;
      Mi,Ni     :integer;
      Ans       :integer;
      ex        :boolean;

begin
 FillChar(A,SizeOf(A),0);
 FillChar(B,SizeOf(B),0);
 FillChar(AU,SizeOf(AU),0);
 FillChar(BU,SizeOf(BU),0);
 Read(M,N,K);
 for i:=1 to K do begin
   read(ver[i,1],ver[i,2]);
   inc(a[ver[i,1]]);
   inc(b[ver[i,2]]);
  end;
 Ans:=0;
 Ni:=N;
 Mi:=M;
 repeat
 ex:=true;
 for i:=1 to K do
  if a[ver[i,1]]=1 then
   if AU[ver[i,1]]=0 then begin
    Ans:=Ans+1;
    if BU[ver[i,2]]=0 then dec(Mi);
    BU[ver[i,2]]:=1;
    AU[ver[i,1]]:=1;
    dec(Ni);
   end;
 for i:=1 to K do
  if b[ver[i,2]]=1 then
   if BU[ver[i,2]]=0 then begin
    Ans:=Ans+1;
    if AU[ver[i,1]]=0 then dec(Ni);
    AU[ver[i,1]]:=1;
    BU[ver[i,2]]:=1;
    dec(Mi);
   end;
 for i:=1 to K do
  if BU[ver[i,2]]=1 then
   if AU[ver[i,1]]=0 then begin
    ex:=false;
    dec(a[ver[i,1]]);
    if a[ver[i,1]]=0 then Ans:=Ans+1;
   end;
 until ex;
 Ans:=Ans+Mi+Ni;
 Writeln(Ans);
end.