Piotr Czajkowski 22 小時之前
父節點
當前提交
9628e0e572
共有 1 個文件被更改,包括 4 次插入0 次删除
  1. 4 0
      20/code.go

+ 4 - 0
20/code.go

@@ -103,6 +103,10 @@ func hike(start *Point, matrix [][]byte, xMax, yMax int, cheat bool, cheats map[
 
 		newMoves := getMoves(current, matrix, xMax, yMax, cheat, cheats)
 		for _, newMove := range newMoves {
+			if cheat && newMove.cost >= bestWithoutCheating {
+				continue
+			}
+
 			if visited[newMove.key()] == 0 || visited[newMove.key()] >= newMove.cost {
 				moves = append(moves, newMove)
 				visited[newMove.key()] = newMove.cost