---
# System prepended metadata

title: '[Kattis] GlitchBot 中文翻譯'
tags: [kattis, 中文翻譯]

---

 # [Kattis] GlitchBot

>題目連結:https://open.kattis.com/problems/glitchbot 

 

 One of our delivery robots is malfunctioning! The job of the robot is simple; it should follow a list of instructions in order to reach a target destination. The list of instructions is originally correct to get the robot to the target. However, something is going wrong as we upload the instructions into the robot’s memory. During the upload, one random instruction from the list takes on a different value than intended. Yes, there is *always* a single bad instruction in the robot’s memory and it *always* results in the robot arriving at an incorrect destination as it finishes executing the list of instructions.
:::success
我們的一台交付機器人出現故障！這個機器人的工作很簡單：它應該按照一個指令列表來到達目標地點。最初的指令列表是正確的，可以將機器人帶到目標地點。然而，在將指令上傳到機器人的記憶中時，出了一些問題。在上傳過程中，指令列表中的一個隨機指令的值與預期的值不同。是的，機器人的記憶中總是有一條錯誤的指令，它總是導致機器人在執行指令列表時到達錯誤的目的地。
:::
 The robot can execute the instructions “Left”, “Right”, and “Forward”. The “Left” and “Right” instructions do not result in spatial movement but result in a $90$-degree turn in the corresponding direction. “Forward” is the only instruction that results in spatial movement, causing the robot to move one unit in the direction it is facing. The robot always starts at the origin $(0,0)$ of a grid and faces north along the positive y-axis.
:::success
機器人可以執行指令“Left”、“Right”和“Forward”。指令“Left”和“Right”不會導致空間運動，而會使機器人在相應方向上轉向$90$度。只有指令“Forward”會導致空間運動，使機器人向它所面朝的方向移動一個單位。機器人總是從坐標原點$(0,0)$開始，並朝著正的y軸方向，即北方。
:::
 Given the coordinates of the target destination and the list of instructions that the robot has in its memory, you are to identify a correction to the instructions to help the robot reach the proper destination.
:::success
給定目標地點的坐標以及機器人記憶中的指令列表，你需要找到一個修正的指令，以幫助機器人到達正確的目的地。
:::
 ## Input

 The first line of the input contains the $x$ and $y$ integer coordinates of the target destination, where $−50≤x≤50$ and $−50≤y≤50$. The following line contains an integer $n$ representing the number of instructions in the list, where $1≤n≤50$. The remaining $n$ lines each contain a single instruction. These instructions may be: “Left”, “Forward”, or “Right”.
:::success
輸入的第一行包含目標地點的整數坐標$x$和$y$，其中$−50≤x≤50$且$−50≤y≤50$。接下來一行包含一個整數$n$，表示指令列表中的指令數，其中$1≤n≤50$。接下來的$n$行每行包含一條指令。這些指令可以是：“Left”、“Forward”或“Right”。
:::
 ## Output

 Identify how to correct the robot’s instructions by printing the line number (starting at $1$) of an incorrect input instruction, followed by an instruction substitution that would make the robot reach the target destination. If there are multiple ways to fix the instructions, report the fix that occurs for the earliest line number in the sequence of instructions. There is always exactly one unique earliest fix.
:::success
通過打印不正確的輸入指令的行號（從1開始），後跟一條替換指令，來確定如何修正機器人的指令，以使其達到目標地點。如果有多種方法可以修正指令，請報告在指令序列中的最早行號上發生的修正。只有一個唯一的最早修正。
:::
 ### Sample Input 1


 
```
3 2
11
Forward
Right
Forward
Forward
Left
Forward
Forward
Left
Forward
Right
Forward
```
 
 ### Sample Output 1 

 
```
8
Right
```
 

 ### Sample Input 2


 
```
-1 1
3
Right
Left
Forward
```
 
 ### Sample Output 2 

 
```
1
Forward
```
###### 翻譯錯誤請留言告知
