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
|
||||||||||||
2015-06-16 04:34:27
nice problem |
||||||||||||
2015-05-31 09:57:58 Dipti Singhal
Getting WA in 20th test case! |
||||||||||||
2015-03-19 17:03:42 Potra Vlad
What's so special about 20th test case? |
||||||||||||
2014-12-03 16:41:40 Archit Jain
nice one! |
||||||||||||
2014-12-02 22:18:16 Sumit
Guys take care about the increasing order condition cost me 5 wa's |
||||||||||||
2014-11-30 07:04:30 vishal
wa on 20th test case..!! |
||||||||||||
2014-11-11 12:08:48 Ankur Singh
nice problem ... taught me kernel DAG |
||||||||||||
2014-10-31 07:16:01 Ayush Vatsa
very weak test cases.....wrong algorithm is getting accepted |
||||||||||||
2014-08-15 21:25:29 mohsin mohammad
Easy graph problem.... |
||||||||||||
2014-06-15 10:59:42 Adarsh Mohata
Exactly same problem as TOUR..just need to change the constraints.Also,the test cases are very weak compared to TOUR Last edit: 2014-06-15 11:00:33 |