Problem 4020 --Simply Syntax

4020: Simply Syntax

"
Time Limit $1$ 秒/Second(s) Memory Limit $512$ 兆字节/Megabyte(s)
提交总数 $312$ 正确数量 $542$
裁判形式 标准裁判/Standard Judge 我的状态 尚未尝试
难度 分类标签 字符串 递归 递归下降分析 编译原理
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
递归下降分析,字符串处理

推荐代码 查看4020 所有题解 上传题解视频得图灵币

本题记录 用 户(点击查看用户) 运行号(点击购买题解) 时 间
算法最快[$0 $ms] . 1059624 2024-01-10 21:35:46
内存最少[$1120 $KB] 奥利给给 975039 2023-06-30 15:43:13
第一AC 木槿. 958312 2023-04-24 09:19:34
第一挑战 木槿. 958312 2023-04-24 09:19:34

赛题来源/所属竞赛 East Central North America 1994 N/A

竞赛编号 竞赛名称 竞赛时间 访问比赛
1769 2023-2024-1学期<编译原理> 第11-12周练习:LL(k)文法实验【21计算机1234】 2023-11-13 00:00:00 请登录
1768 2023-2024-1学期<编译原理> 第9-10周练习:递归下降语法实验【21计算机1234】 2023-10-30 00:00:00 请登录
1747 2022-2023-2学期<编译原理> 第11-12周练习:LL(k)文法实验【20计算机12345】 2023-05-07 00:00:00 请登录
1746 2022-2023-2学期<编译原理> 第10-11周练习:递归下降语法实验【20计算机12345】 2023-04-24 00:00:00 请登录