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
hide comments
shafwanur010:
2020-03-30 18:06:37
Remember -
|
|
aryan12:
2020-03-12 22:51:57
AC in 2 gos. Saved by .01 seconds from a TLE. #0.99 #LuckFavoursMe |
|
daihandsome:
2020-03-12 09:25:35
time limit on test 20 bruh bruh:< |
|
coolio_1:
2020-03-05 03:00:10
AC in 1 go. Took a lot of effort. |
|
sangmai:
2020-02-21 10:50:36
I believe that there are duplicated edges in test case 20. AC after handling that case. |
|
transonviet:
2020-01-21 08:54:47
Wonderful prob =))) ac in one go |
|
swapscool:
2020-01-17 09:23:04
Weak test cases. Getting ac by just printing vertices (sorted order) present in the scc's whose size is greater than 1. |
|
tanroop:
2019-10-24 20:16:08
Which one is 20th TC. Spojtoolkit is a bit confusing |
|
scolar_fuad:
2019-09-24 08:11:41
Straight forward scc |
|
scolar_fuad:
2019-09-24 07:13:34
what it would be if there exist more than one ssc in a graph |
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 |