How to fully solve this problem with 100 points

what is the stategy to solve this problem with 100 points, i solved this with dfs and get 50 points, but for the 100 points, the constraints are very strict, so how should i approach this problem