CF687E TOF
Description
Today Pari gave Arya a cool graph problem. Arya wrote a non-optimal solution for it, because he believes in his ability to optimize non-optimal solutions. In addition to being non-optimal, his code was buggy and he tried a lot to optimize it, so the code also became dirty! He keeps getting Time Limit Exceeds and he is disappointed. Suddenly a bright idea came to his mind!
Here is how his dirty code looks like:
`
dfs(v)
{
set count[v] = count[v] + 1
if(count[v] < 1000)
{
foreach u in neighbors[v]
{
if(visited[u] is equal to false)
{
dfs(u)
}
break
}
}
set visited[v] = true
}
main()
{
input the digraph()
TOF()
foreach 1
dfs(v)
{
set count[v] = count[v] + 1
if(count[v] < 1000)
{
foreach u in neighbors[v]
{
if(visited[u] is equal to false)
{
dfs(u)
}
break
}
}
set visited[v] = true
}
main()
{
input the digraph()
TOF()
foreach 1
Input Format
The first line of the input contains two integers $ n $ and $ m $ ( $ 1
Output Format
Print a single integer — the minimum possible number of dfs calls that can be achieved with permuting the edges.