cswork / OA打开练习工作台

Goldman SachsOA #8

Encircular

简单可在线判题

考点(AI 标注)模拟/实现位运算

A robot starts at coordinates (0,0) facing north and executes the commands G (move forward one step), L (turn left in place), and R (turn right in place). The command string repeats forever. Determine whether the robot's path always stays bounded; output YES if it is bounded, otherwise output NO.

输入格式

The first line contains n (1..10), followed by n lines, each containing a command string of length 1..2500 consisting only of G, L, R.

输出格式

For each command string, in input order, output YES or NO, one result per line.

样例 1

输入:

3
G
GL
GRGRGRGR

输出:

NO
YES
YES

样例 2

输入:

1
R

输出:

YES

样例 3

输入:

1
GLGLGLGL

输出:

YES