implementing the cut road problem