Hello, ↵
↵
I'm trying to solve the last problem in [this](http://mirror.codeforces.com/gym/100676/attachments/download/3333/acm-arabella-collegiate-programming-contest-en.pdf) contest.↵
↵
and [this](https://ideone.com/2C02bU) is my code, my idea is to change every strongly connected component into one node because the cost of travailing between it's nodes is **ZERO**, this can be done by removing all bridges and then applying union find on elements of the other edges.↵
↵
Then I create new adjList using elements of the removed edges "i.e bridges", the new graph will form a tree.↵
↵
Then I apply DFS two times to find the longest path in a tree.↵
↵
Last step is to follow the longest path and save the sum of edges on the sides of each node, take the maximum sum between the left and right sum.↵
↵
↵
Sometimes it returns TLE and sometimes RTE.↵
↵
What could be the mistake, and is there a better way to solve it.↵
↵
Thanks-.↵
↵
EDIT: now [this](https://ideone.com/2C02bU) code gets WA
↵
I'm trying to solve the last problem in [this](http://mirror.codeforces.com/gym/100676/attachments/download/3333/acm-arabella-collegiate-programming-contest-en.pdf) contest.↵
↵
and [this](https://ideone.com/2C02bU) is my code, my idea is to change every strongly connected component into one node because the cost of travailing between it's nodes is **ZERO**, this can be done by removing all bridges and then applying union find on elements of the other edges.↵
↵
Then I create new adjList using elements of the removed edges "i.e bridges", the new graph will form a tree.↵
↵
Then I apply DFS two times to find the longest path in a tree.↵
↵
Last step is to follow the longest path and save the sum of edges on the sides of each node, take the maximum sum between the left and right sum.↵
↵
↵
Sometimes it returns TLE and sometimes RTE.↵
↵
What could be the mistake, and is there a better way to solve it.↵
↵
Thanks
↵
EDIT: now [this](https://ideone.com/2C02bU) code gets WA