Submit | All submissions | Best solutions | Back to list |
CAPCITY - Capital City |
There are N cities in Flatland connected with M unidirectional roads. The cities are numbered from 1 to N. The Flat Circle of Flatland (FCF) wants to set up a new capital city for his kingdom. For security reasons, the capital must be reachable from all other cities of Flatland. FCF needs the list of all candidate cities. You are the chief programmer at FACM (Flat Association for Computing Machinery) responsible for providing the list to FCF as soon as possible.
Input
The first line of the input file contains two integers: 1 ≤ N ≤ 100,000 and 1 ≤ M ≤ 200,000. Each of the following M lines contains two integers 1 ≤ A, B ≤ N denoting a road from A to B.
Output
The output file contains an integer denoting the number of candidate cities followed by the list of candidate cities in increasing order.
Example
Input: 4 4 1 2 3 2 4 3 2 1 Output: 2 1 2
Added by: | Narek Saribekyan |
Date: | 2010-06-20 |
Time limit: | 1s-4s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: NODEJS OBJC PERL6 SQLITE VB.NET |
Resource: | Armenian TST 2010, Round 2 |
hide comments
|
||||||||||||
2016-04-10 11:15:08 [Mayank Pratap]
Spent a lot of time in this problem... Finally AC :) |
||||||||||||
2016-03-30 12:36:24 minhthai
too...many...lines...of...code |
||||||||||||
2016-02-23 14:31:41 GAURAV CHANDEL
Lovely Graph Problem.. |
||||||||||||
2016-01-30 09:56:55 kartikay singh
Nice problemo... :D |
||||||||||||
2016-01-25 19:28:53 Deepak
weak test cases...was sure my solution will give WA..but got AC..copy paste BOTTOM. |
||||||||||||
2016-01-25 18:54:55 Arjav
nice one ...... think reverse!!! |
||||||||||||
2016-01-25 16:49:33 varun yadav
was afraid to submit,, but got AC in one go,, should be moved to tutorial :p |
||||||||||||
2015-12-24 18:04:27 kejriwal
AC in one go.. :D !! |
||||||||||||
2015-10-22 21:08:24 LEMONICE
Great question! Got to learn a lot! |
||||||||||||
2015-07-03 07:55:01 Saket Sharma
it giving me runtime error :( in test case 20. anyone please give me hint to solve pls. |