A846 | Clockwise Fence--Bronze
来源USACO
时间限制1s
内存限制128MB
通过 / 提交0/0
题目描述
The fence surrounding Farmer John's largest pasture has fallen into disrepair,
and he has finally decided to replace it with a new fence.
Unfortunately, as Farmer John is laying out the new fence, a large bee ends up
chasing him around the pasture, and as a result, the fence ends up following a
rather irregular path. The fence can be described by a string of characters,
each either "N" (north), "E" (east), "S" (south), or "W" (west). Each
character describes a 1-meter run of the fence. For example, if the string is
NESW, this means the fence starts by moving north for 1 meter, then east for 1
meter, then south for 1 meter, then west for 1 meter, returning to its
starting point.
The fence ends at the position where it started, and this is the only point
visited more than once by the path of the fence (and the starting point is
only re-visited once, at the end). As a result, the fence does indeed enclose
a single connected region of the grassy pasture, even though this region could
have a rather strange shape.
Farmer John is curious if the path in which he laid the fence traveled
clockwise (with the enclosed region on the right side of the fence as one
walks along the path of the fence in the order specified by the string) or
counter-clockwise (with the enclosed region on the left side of the fence).
and he has finally decided to replace it with a new fence.
Unfortunately, as Farmer John is laying out the new fence, a large bee ends up
chasing him around the pasture, and as a result, the fence ends up following a
rather irregular path. The fence can be described by a string of characters,
each either "N" (north), "E" (east), "S" (south), or "W" (west). Each
character describes a 1-meter run of the fence. For example, if the string is
NESW, this means the fence starts by moving north for 1 meter, then east for 1
meter, then south for 1 meter, then west for 1 meter, returning to its
starting point.
The fence ends at the position where it started, and this is the only point
visited more than once by the path of the fence (and the starting point is
only re-visited once, at the end). As a result, the fence does indeed enclose
a single connected region of the grassy pasture, even though this region could
have a rather strange shape.
Farmer John is curious if the path in which he laid the fence traveled
clockwise (with the enclosed region on the right side of the fence as one
walks along the path of the fence in the order specified by the string) or
counter-clockwise (with the enclosed region on the left side of the fence).
输入格式
The first line of input contains an integer $N$ ($1 \leq N \leq 20$). Each of
the next $N$ lines contains a string of length at least 4 and at most 100,
describing a single fence path.
the next $N$ lines contains a string of length at least 4 and at most 100,
describing a single fence path.
输出格式
For each of the $N$ fence paths described in the input, output a line
containing either "CW" (clockwise) or "CCW" (counterclockwise).
containing either "CW" (clockwise) or "CCW" (counterclockwise).
输入输出样例
输入 #1
2 NESW WSSSEENWNEESSENNNNWWWS
输出 #1
CW CCW
The two fence paths with @ denoting the starting point:
*>*
^ v
@<*
*<*<*<*
v ^
*<@ *
v ^
* *>*>* *
v ^ v ^
* *<* * *
v ^ v ^
*>*>* *>*
*>*
^ v
@<*
*<*<*<*
v ^
*<@ *
v ^
* *>*>* *
v ^ v ^
* *<* * *
v ^ v ^
*>*>* *>*
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted