VaR {left indicates that the vertex root has not left the stack. vis indicates whether the vertex root has been accessed} I, n, m, now, time, color, top: longint; V: array [0 .. 10001] of record start: longint; end; E: array [0 .. 100001] of record y, next: longint; end; dfn, low, stack, encolor: array [0 .. 10001] of longint; vis, left: array [0 .. 10001] of Boolean; Procedure indata; var I, XX, YY, OP: longint; begin time: = 0; color: = 0; top: = 0; fillchar (E, sizeof (E), 0); fillchar (v, sizeof (V), 0); fillchar (dfn, sizeof (dfn), 0); fillchar (low, sizeof (low), 0); fillchar (VIS, sizeof (VIS), 0); fillchar (left, sizeof (left), 1); fillchar (encolor, sizeof (encolor), 0); end; Procedure Tarjan (root: longint); var te, TV, ttimes: longint; begin Inc (time); dfn [root]: = time; low [root]: = time; Inc (top); stack [Top]: = root; {point root to stack} left [root]: = false; vis [root]: = true; Te: = V [root]. start; while (te <> 0) Do begin TV: = E [Te]. y; if not left [TV] Then low [root]: = min (low [root], dfn [TV]); if not vis [TV] Then begin Tarjan (TV); low [root]: = min (low [root], low [TV]); end; Te: = E [Te]. next; end; If (dfn [root] = low [root]) then begin Inc (color); TV: = 0; while (TV <> root) Do begin TV: = stack [Top]; Dec (top); encolor [TV]: = color; left [TV]: = true; end;