srm573 div1 250 450 graph theory (BFS + DP)