Why I get WA? Pelase, help me!!!!!!! (+) 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!!!!!!! (+) 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. |