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 1320. Graph Decomposition

WA#7,need help!!!
Posted by Oyh's 小号 17 Apr 2010 13:01
who can help me? I WA on #7.Why?

here is my program:
var
  a:array[1..1000]of longint;
  b:array[1..1000,1..1000]of boolean;
  n,i,j,x,y,m:longint;
  c:boolean;
  function find(x,y:longint):boolean;
    var
      i:longint;
    begin
      if b[x,y] then exit(false);
      for i:=1 to m do
        if (b[a[i],x])and(b[a[i],y])then
          begin
            b[x,y]:=true;b[y,x]:=true;
            exit(false);
          end;
      exit(true);
    end;

begin
  while not seekeof do
    begin
      readln(x,y);
      b[x,x]:=true;b[y,y]:=true;
      b[x,y]:=true;b[y,x]:=true;

      c:=true;
      for j:=1 to m do
        if a[m]=x then begin c:=false;break;end;
      if c then
        begin
          inc(m);a[m]:=x;
          for i:=1 to m do
            if find(a[i],x) then
              begin
                writeln(0);halt;
              end;
        end;

      c:=true;
      for j:=1 to m do
        if a[m]=y then begin c:=false;break;end;
      if c then
        begin
          inc(m);a[m]:=y;
          for i:=1 to m do
            if find(a[i],y) then
              begin
                writeln(0);halt;
              end;
        end;
    end;
  writeln(1);
end.
Re: WA#7,need help!!!
Posted by gautamvs 14 Sep 2012 23:14
Pls check for the following case:

5 6
5 8
5 9
6 7
8 9
9 10

Answer should be 1
Re: WA#7,need help!!!
Posted by Vladimir Plyashkun [USU] 4 Feb 2014 18:11
Test 7 has invert vertexes.
10 1
1 2

asn: 1

I have many times WA, because my programm doesnt check it.