2 leavetype
=array [0..500] of boolean;
6 know
:array [0..500,0..500] of longint;
9 function deg(i
:longint):longint;
16 if (not lea
[j
]) and (know
[i
,j
]=1) then inc(deg
);
19 function connect(i
:longint):longint;
24 for j
:=1 to n
do if (not lea
[j
]) and (know
[i
,j
]=1) then break
;
28 function noknow
:boolean;
36 if (know
[i
,j
]=1) and (not (lea
[i
])) and (not (lea
[j
])) then exit(false);
39 function pass(i
:longint):boolean;
42 if (lea
[i
]) or (deg(i
)=0) then exit(false);
45 procedure save(p
:longint);
51 function done(i
:longint):boolean;
59 if (know
[i
,j
]=1) and (deg(j
)=2) then
60 if connect(j
)<i
then exit
;
64 procedure dfs(s
:longint);
71 if noknow
then begin save(s
-1); exit
; end;
77 if lea
[i
] then continue
;
86 else if j
>(n
-s
-k
+1) div 2 then
100 if pass(i
) and not done(i
) then
114 know
[p
,q
]:=1; know
[q
,p
]:=1;
115 until (p
=0) and (q
=0);
119 for p
:=1 to n
do if leave
[p
] then write(p
,' ');