Help: Visiting Friend (MCO16405)

I passed all the cases of this problem except two. I can’t find where my logic giving wrong results.
can anyone check and correct me.

Problem is based on finding SCC and DP on DAG form by SCC.

Problem Link :- VisitingFriend(MCO16405)

My Solution :- MYSOLUTION