ACM Commands

Commands

Time Limit:1000MS  Memory Limit:65536K
Total Submit:51 Accepted:14

Description

You are standing on some arbitrary point in the infinite plane.
You are given some string commands that contains the commands you have to execute. Each character of each element of commands is one command. The commands must be executed in the given order: first you execute all commands in the first element of commands one by one, then those in the second element, etc.
There are only three types of commands: 'S' means "step forward", 'L' means "turn 90 degrees to the left", and 'R' means "turn 90 degrees to the right". All your steps have the same length.
You will be executing the commands forever: after you execute the last character of the last element of commands, you will always start from the beginning again.
We say that your path is bounded if there is some positive real number R such that while executing the infinite sequence of steps you will never leave the circle with radius R steps and center at your starting location.
You should determine whether your path will be bounded or not. Return the string "bounded" (quotes for clarity) if the path is bounded and "unbounded" if it is not.
Input:
The first line is a number n,means there are n commands;
And then n lines,every line is a string consist of 'S','R','L',means n commands;
Output:
Output one line "bounded" if there is some positive real number R such that while executing the infinite sequence of steps you will never leave the circle with radius R steps and center at your starting location.
else output one line "unbounded";
Constraints
-
commands will contain between 1 and 50 elements, inclusive.
-
Each element in commands will contain between 1 and 50 characters, inclusive.
-
Each character in each element of commands will be one of 'S', 'L', and 'R'.

Input

The first line is a number n,means there are n commands;
And then n lines,every line is a string consist of 'S','R','L',means n commands;

Output

Output one line "bounded" if there is some positive real number R such that while executing the infinite sequence of steps you will never leave the circle with radius R steps and center at your starting location.
else output one line "unbounded";

Sample Input

1
L
1
SRSL
2
SSSS
R
4
SRSL
LLSSSSSSL
SSSSSS
L

 

Sample Output

bounded
unbounded
bounded
unbounded

 

Source

TopCoder

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值