|
|
back to boardWhy so complicated!!!!! Look at this solution. It's very easy and it works!!!!!!! var n:integer; i,j,c:integer; a:array[1..100,1..100] of boolean; b:array[1..100] of boolean; s:array[1..100] of integer; procedure ds(x:integer); var i:integer; begin b[x]:=false; for I:=1 to n do if (a[x,i]) and (b[i]) then ds(i); dec(c); s[c]:=x; end; begin for I:=1 to 100 do for J:=1 to 100 do a[i,j]:=false; for i:=1 to 100 do b[i]:=true; readln(n); for I:=1 to n do begin repeat read(c); if c<>0 then a[i,c]:=true; until c=0 end; c:=n+1; for I:=1 to n do if b[i] then ds(i); for i:=1 to n do begin write(s[i]); if i<n then write(' '); end; end. That problem is very easy i don't know why u publish such solution :) (-) > Look at this solution. It's very easy and it works!!!!!!! > > var > n:integer; > i,j,c:integer; > a:array[1..100,1..100] of boolean; > b:array[1..100] of boolean; > s:array[1..100] of integer; > > procedure ds(x:integer); > var > i:integer; > begin > b[x]:=false; > for I:=1 to n do > if (a[x,i]) and (b[i]) then ds(i); > dec(c); > s[c]:=x; > end; > > begin > for I:=1 to 100 do for J:=1 to 100 do a[i,j]:=false; > for i:=1 to 100 do b[i]:=true; > > readln(n); > > for I:=1 to n do begin > repeat > read(c); > if c<>0 then a[i,c]:=true; > until c=0 > end; > > c:=n+1; > > for I:=1 to n do if b[i] then ds(i); > for i:=1 to n do begin > write(s[i]); > if i<n then write(' '); > end; > > end. So give shorter solution :-) if you shorter solution,please, post it here. I just don't know how to make it smaller. I just told you "this problem is easy", my solution is equals "in length" to yours, the difference is that i solved this one a lot of time before :) (-) > if you shorter solution,please, post it here. I just don't know how > to make it smaller. I think If I started solving problems from this site earlier than several weeks ago I would also have already solved it :-) Yeah, but my point is that this webboard is for questions only :| (-) > |
|
|