{"trustable":false,"sections":[{"title":"","value":{"format":"HTML","content":"\u003cstyle type\u003d\"text/css\"\u003e\r\nh1,h2,h3,h4,h5,h6{margin-bottom:0;}div.textBG p{margin: 0 0 0.0001pt;}\u003c/style\u003e\r\n\u003cp\u003e\r\n\t\u0026nbsp;\u003c/p\u003e\r\n\u003cp\u003e\r\n\tWrite a program that searches a directed graph for vertices which are inaccessible from a given starting vertex.\u003c/p\u003e\r\n\u003cp\u003e\r\n\t\u0026nbsp;\u003c/p\u003e\r\n\u003cp\u003e\r\n\tA directed graph is represented by \u003ci\u003en\u003c/i\u003e vertices where \u003cimg align\u003d\"MIDDLE\" alt\u003d\"tex2html_wrap_inline31\" height\u003d\"25\" src\u003d\"http://uva.onlinejudge.org/external/2/280img1.gif\" width\u003d\"90\" /\u003e , numbered consecutively \u003cimg align\u003d\"BOTTOM\" alt\u003d\"tex2html_wrap_inline33\" height\u003d\"12\" src\u003d\"http://uva.onlinejudge.org/external/2/280img2.gif\" width\u003d\"44\" /\u003e , and a series of edges \u003ci\u003ep\u003c/i\u003e \u003ctt\u003e-\u0026gt;\u003c/tt\u003e \u003ci\u003eq\u003c/i\u003e which connect the pair of nodes \u003ci\u003ep\u003c/i\u003e and \u003ci\u003eq\u003c/i\u003e in one direction only.\u003c/p\u003e\r\n\u003cp\u003e\r\n\t\u0026nbsp;\u003c/p\u003e\r\n\u003cp\u003e\r\n\tA vertex \u003ci\u003er\u003c/i\u003e is reachable from a vertex \u003ci\u003ep\u003c/i\u003e if there is an edge \u003ci\u003ep\u003c/i\u003e \u003ctt\u003e-\u0026gt;\u003c/tt\u003e \u003ci\u003er\u003c/i\u003e, or if there exists some vertex \u003ci\u003eq\u003c/i\u003e for which \u003ci\u003eq\u003c/i\u003e is reachable from \u003ci\u003ep\u003c/i\u003e and \u003ci\u003er\u003c/i\u003e is reachable from \u003ci\u003eq\u003c/i\u003e.\u003c/p\u003e\r\n\u003cp\u003e\r\n\t\u0026nbsp;\u003c/p\u003e\r\n\u003cp\u003e\r\n\tA vertex \u003ci\u003er\u003c/i\u003e is inaccessible from a vertex \u003ci\u003ep\u003c/i\u003e if \u003ci\u003er\u003c/i\u003e is not reachable from \u003ci\u003ep\u003c/i\u003e.\u003c/p\u003e\r\n\u003cp\u003e\r\n\t\u0026nbsp;\u003c/p\u003e\r\n\u003ch2\u003e\r\n\t\u003cfont color\u003d\"#0070E8\"\u003e\u003ca name\u003d\"SECTION0001001000000000000000\"\u003eInput\u003c/a\u003e\u003c/font\u003e\u003c/h2\u003e\r\n\u003cp\u003e\r\n\tThe input data for this program consists of several directed graphs and starting nodes.\u003c/p\u003e\r\n\u003cp\u003e\r\n\t\u0026nbsp;\u003c/p\u003e\r\n\u003cp\u003e\r\n\tFor each graph, there is first one line containing a single integer \u003ci\u003en\u003c/i\u003e. This is the number of vertices in the graph.\u003c/p\u003e\r\n\u003cp\u003e\r\n\t\u0026nbsp;\u003c/p\u003e\r\n\u003cp\u003e\r\n\tFollowing, there will be a group of lines, each containing a set of integers. The group is terminated by a line which contains only the integer 0. Each set represent a collection of edges. The first integer in the set, \u003ci\u003ei\u003c/i\u003e, is the starting vertex, while the next group of integers, \u003cimg align\u003d\"MIDDLE\" alt\u003d\"tex2html_wrap_inline73\" height\u003d\"25\" src\u003d\"http://uva.onlinejudge.org/external/2/280img3.gif\" width\u003d\"44\" /\u003e , define the series of edges \u003ci\u003ei\u003c/i\u003e \u003ctt\u003e-\u0026gt;\u003c/tt\u003e \u003cimg align\u003d\"MIDDLE\" alt\u003d\"tex2html_wrap_inline77\" height\u003d\"25\" src\u003d\"http://uva.onlinejudge.org/external/2/280img4.gif\" width\u003d\"41\" /\u003e \u003ctt\u003e-\u0026gt;\u003c/tt\u003e \u003ci\u003ek\u003c/i\u003e, and the last integer on the line is always 0. Each possible start vertex \u003ci\u003ei\u003c/i\u003e, \u003cimg align\u003d\"MIDDLE\" alt\u003d\"tex2html_wrap_inline83\" height\u003d\"25\" src\u003d\"http://uva.onlinejudge.org/external/2/280img5.gif\" width\u003d\"70\" /\u003e will appear once or not at all. Following each graph definition, there will be a one line containing list of integers. The first integer on the line will specify how many integers follow. Each of the following integers represents a start vertex to be investigated by your program. The next graph then follows. If there are no more graphs, the next line of the file will contain only the integer 0.\u003c/p\u003e\r\n\u003cp\u003e\r\n\t\u0026nbsp;\u003c/p\u003e\r\n\u003ch2\u003e\r\n\t\u003cfont color\u003d\"#0070E8\"\u003e\u003ca name\u003d\"SECTION0001002000000000000000\"\u003eOutput\u003c/a\u003e\u003c/font\u003e\u003c/h2\u003e\r\n\u003cp\u003e\r\n\tFor each start vertex to be investigated, your program should identify all the vertices which are inaccessible from the given start vertex. Each list should appear on one line, beginning with the count of inaccessible vertices and followed by the inaccessible vertex numbers.\u003c/p\u003e\r\n\u003cp\u003e\r\n\t\u0026nbsp;\u003c/p\u003e\r\n\u003ch2\u003e\r\n\t\u003cfont color\u003d\"#0070E8\"\u003e\u003ca name\u003d\"SECTION0001003000000000000000\"\u003eSample Input\u003c/a\u003e\u003c/font\u003e\u003c/h2\u003e\r\n\u003cp\u003e\r\n\t\u0026nbsp;\u003c/p\u003e\r\n\u003cpre\u003e\r\n3\r\n1 2 0\r\n2 2 0\r\n3 1 2 0\r\n0\r\n2 1 2\r\n0\u003c/pre\u003e\r\n\u003cp\u003e\r\n\t\u0026nbsp;\u003c/p\u003e\r\n\u003ch2\u003e\r\n\t\u003cfont color\u003d\"#0070E8\"\u003e\u003ca name\u003d\"SECTION0001004000000000000000\"\u003eSample Output\u003c/a\u003e\u003c/font\u003e\u003c/h2\u003e\r\n\u003cp\u003e\r\n\t\u0026nbsp;\u003c/p\u003e\r\n\u003cpre\u003e\r\n2 1 3\r\n2 1 3\u003c/pre\u003e"}}]}