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

建议使用的浏览器:

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

1126:Simply Syntax

题目描述
In the land of Hedonia the official language is Hedonian. A Hedonian professor had noticed that many of her students still did not master the syntax of Hedonian well. Tired of correcting the many syntactical mistakes, she decided to challenge the students and asked them to write a program that could check the syntactical correctness of any sentence they wrote. Similar to the nature of Hedonians, the syntax of Hedonian is also pleasantly simple. Here are the rules:


0.The only characters in the language are the characters p through z and N, C, D, E, and I.

1.Every character from p through z is a correct sentence.

2.If s is a correct sentence, then so is Ns.

3.If s and t are correct sentences, then so are Cst, Dst, Est and Ist.

4.Rules 0. to 3. are the only rules to determine the syntactical correctness of a sentence.

You are asked to write a program that checks if sentences satisfy the syntax rules given in Rule 0. - Rule 4.
输入解释
The input consists of a number of sentences consisting only of characters p through z and N, C, D, E, and I. Each sentence is ended by a new-line character. The collection of sentences is terminated by the end-of-file character. If necessary, you may assume that each sentence has at most 256 characters and at least 1 character.
输出解释
The output consists of the answers YES for each well-formed sentence and NO for each not-well-formed sentence. The answers are given in the same order as the sentences. Each answer is followed by a new-line character, and the list of answers is followed by an end-of-file character.
输入样例
Cp
Isz
NIsz
Cqpq
输出样例
NO
YES
YES
NO

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

源链接: POJ-1126

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

共提交 0

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