SafetyKitOA #2
Robot Circle Existence (Infinite Loop Boundedness)
估计中等可在线判题
考点(AI 标注)模拟/实现位运算
A command string made of G (move forward), L, and R (turn in place) is executed repeatedly; determine whether the robot's path is bounded.
输入格式
The first line contains q (1≤q≤1000), followed by q lines of command strings of length 1..10000 consisting only of the characters G/L/R.
输出格式
For each string, output YES (bounded) or NO (unbounded).
样例 1
输入:
3
G
GL
RGRG
输出:
NO
YES
YES
样例说明
Derive a linear scan/dynamic programming solution directly from the problem rules; the examples have been checked one by one against an independently built oracle.