经典简约
清爽简洁,回归本真
液态水晶
毛玻璃+霓虹光带
赛博朋克
霓虹故障艺术风
🚫
违规操作检测
禁止使用右键菜单
⚠️ 此操作已被系统记录
1

Hot Spot

📝 题解 🔵 仅限 C++
题目描述
<p> Hot Spot is a single player game played on a 4 by 4 game board. The purpose of the game is to move a red robot from its current location on the board to the top left corner. The game board may also contain green and blue robots. Each square of the game board can be occupied by no more than one robot at any time. </p> <p> A robot may move in one of two ways: </p> <ol> <li> If two robots are adjacent horizontally or vertically (but not diagonally), one of them may jump over the other to the immediately adjacent square, provided that square is empty. For example, if robot a is immediately to the left of robot b, robot a may jump to the square immediately to the right of robot b. </li> <li> If three robots are adjacent in a line (again not diagonally), one of them may jump over the other two, provided the destination square is empty. For example, if robot b is immediately to the right of robot a and robot c is immediately to the right of robot b, robot a may jump to the square immediately to the right of robot c. </li> </ol> <p> Every jump only changes the positions of the existing robots; robots are never removed from or added to the game board. </p> <p> A blue robot is never allowed to be adjacent horizontally or vertically to another blue robot or to the red robot. </p> <p> Given the initial configuration of the game board, determine the minimum number of jumps required to move the red robot into the top left corner. </p>
输入格式
<p> The input specifies the initial position of the board using four lines, each containing four characters. Each character may be either R, indicating the red robot, B, indicating a blue robot, G, indicating a green robot, or a period (.), indicating an empty square. </p>
输出格式
<p> Output a single line containing a single integer, the minimum number of jumps required for the red robot to reach the top left square of the game board. </p> <h3> &nbsp; </h3>
样例
样例输入 1
.GR. .... .... ....
样例输出 1
1
提交代码
请先登录后提交

🤖 AI 解题助手

DeepSeek
就绪
👋 你好!我是 AI 解题助手。
我已阅读了这道题,可以帮你分析思路、提供代码示例。
⚠️ 请先登录后使用