当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

1530:Slurpys

题目描述
Recognizing strings based on a set of restrictions is a common computational problem.
A Slurpy is a string of characters that has certain properties. Your program will read in strings of characters and output whether or not they are Slurpys.

A Slump is a character string that has the following properties:

1. Its first character is either a 'D' or an 'E'.

2. The first character is followed by a string of one or more 'F's.

3. The string of one or more 'F's is followed by either a Slump or a 'G'. The Slump or 'G' that follows the F's ends the Slump. For example DFFEFFFG is a Slump since it has a 'D' for its first character, followed by a string of two F's, and ended by the Slump 'EFFFG'.

4. Nothing else is a Slump.

A Slimp is a character string that has the following properties:

1. Its first character is an 'A'.

2. If it is a two character Slimp then its second and last character is an 'H'.

3. If it is not a two character Slimp then it is in one of these two forms:
a) 'A' followed by 'B' followed by a Slimp followed by a 'C'.
b) 'A' followed by a Slump (see above) followed by a 'C'.

4. Nothing else is a Slimp.

A Slurpy is a character string that consists of a Slimp followed by a Slump.

Examples

Slumps: DFG, EFG, DFFFFFG, DFDFDFDFG, DFEFFFFFG
Not Slumps: DFEFF, EFAHG, DEFG, DG, EFFFFDG
Slimps: AH, ABAHC, ABABAHCC, ADFGC, ADFFFFGC, ABAEFGCC, ADFDFGC
Not Slimps: ABC, ABAH, DFGC, ABABAHC, SLIMP, ADGC
Slurpys: AHDFG, ADFGCDFFFFFG, ABAEFGCCDFEFFFFFG
Not Slurpys: AHDFGA, DFGAH, ABABCC
输入解释
The first line contains an integer N between 1 and 10 describing how many strings of characters are represented. The next N lines each contain a string of 1 to 60 alpha characters.
输出解释
The first line of output should read SLURPYS OUTPUT. Each of the next N lines of output should consist of either YES or NO depending on whether or not the corresponding input line is a Slurpy. The last line of output should read END OF OUTPUT.
输入样例
2
AHDFG
DFGAH
输出样例
SLURPYS OUTPUT
YES
NO
END OF OUTPUT

该题目是Virtual Judge题目,来自 北京大学POJ

题目来源 Mid-Atlantic 1996

源链接: POJ-1530

最后修改于 2020-10-29T06:06:28+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
1000 10000