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.
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.
The output file contains an integer denoting the number of candidate cities followed by the list of candidate cities in increasing order.
Awesome One!!!!Don't forget to print the cities in increasing order!!!!Similar problem TOUR !!:P
Weak test cases..No test cases for 0 capital city..Last edit: 2018-06-06 08:41:55
Last edit: 2018-05-20 13:51:55
AC in one Go :-p
Honestly, is this solvable with java? Maybe I'm just bad.
My 20th test case is accepted when I ran my DFS on reverse graph starting from every single node which is not explored.There is no case where the graph contains components that are not at all connected to each other. So, there is at least one capital city always.Last edit: 2018-02-09 15:01:00
Getting WA on TEST CASE 20.Can Anyone Tell why and what it could be?
My 2nd submission was a wrong code, but got AC
@scorpion_ajay pls tell me where writen about its no cases without any capital city? I cant find itLast edit: 2017-09-14 17:45:15
Bad time limit for java ;(