← 返回 atlassian 的题目列表Board Game Reachability with Dice Rolls and Teleporters
类型:online_judge
atlassian
In a board game, you start from a certain position and move forward by rolling dice. The board has teleporters, each defined as a pair of positions (e.g., [10, 8] means from tile 10 teleport to tile 8).
Problem Statement:
Given a starting position start and a dice with a certain number of faces.
Calculate all possible destinations within one dice roll.
Determine if it is possible to reach the end of the board, which is the last tile, using teleporters to assist if necessary.
Input Format:
start: An integer representing the starting position of the player.
dice: An integer representing the number of faces of the dice (e.g., 6 means a 6-sided die).
teleporters: An array of strings, each in the format "x,y", meaning teleport from position x to position y.
Output Format:
Return a boolean value indicating whether it is possible to reach the end of the board.
Test Case:
Input: start = 0, dice = 6, teleporters = ["10,8", "11,5", "12,7", "13,9"]
Output: True
Explanation: By using the dice moves and teleporters, it is possible to reach the last tile from the starting point.
Example
Input
0 6 "10,8" "11,5" "12,7" "13,9"