You are given a directed graph, where some vertices are initially painted and some are not, and two vertices and . Please paint the minimum number of additional vertices so that there is a path from to that only passes through painted vertices.
Input consists of several cases. Every case begins with the number of vertices , the starting vertex and the final vertex . Next comes a number , followed by different arcs where . Follow a number , followed by the vertices initially painted. Assume , , , and . The vertices are numbered starting at 0.
For every case, print the minimum number of vertices to paint so that there is a path from to that only passes through painted vertices, and included. If it is impossible, state so.
Author: Salvador Roura
Generation: 2026-01-25T11:52:30.123Z
© Jutge.org, 2006–2026.
https://jutge.org