CF113A.Grammar Lessons
普及/提高-
通过率:0%
时间限制:5.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Petya got interested in grammar on his third year in school. He invented his own language called Petya's. Petya wanted to create a maximally simple language that would be enough to chat with friends, that's why all the language's grammar can be described with the following set of rules:
- There are three parts of speech: the adjective, the noun, the verb. Each word in his language is an adjective, noun or verb.
- There are two genders: masculine and feminine. Each word in his language has gender either masculine or feminine.
- Masculine adjectives end with -lios, and feminine adjectives end with -liala.
- Masculine nouns end with -etr, and feminime nouns end with -etra.
- Masculine verbs end with -initis, and feminime verbs end with -inites.
- Thus, each word in the Petya's language has one of the six endings, given above. There are no other endings in Petya's language.
- It is accepted that the whole word consists of an ending. That is, words "lios", "liala", "etr" and so on belong to the Petya's language.
- There aren't any punctuation marks, grammatical tenses, singular/plural forms or other language complications.
- A sentence is either exactly one valid language word or exactly one statement.
Statement is any sequence of the Petya's language, that satisfy both conditions:
- Words in statement follow in the following order (from the left to the right): zero or more adjectives followed by exactly one noun followed by zero or more verbs.
- All words in the statement should have the same gender.
After Petya's friend Vasya wrote instant messenger (an instant messaging program) that supported the Petya's language, Petya wanted to add spelling and grammar checking to the program. As Vasya was in the country and Petya didn't feel like waiting, he asked you to help him with this problem. Your task is to define by a given sequence of words, whether it is true that the given text represents exactly one sentence in Petya's language.
佩佳在三年级时对语法产生了兴趣。他发明了一种名为“佩佳语”的自创语言。“佩佳语”旨在成为一种极简的语言,足以满足与朋友日常聊天的需求,因此其全部语法规则可由以下集合描述:
- 词性共有三种:形容词、名词、动词。该语言中的每个单词必为形容词、名词或动词之一。
- 性别共有两种:阳性与阴性。该语言中的每个单词必为阳性或阴性之一。
- 阳性形容词以
-lios结尾,阴性形容词以-liala结尾。 - 阳性名词以
-etr结尾,阴性名词以-etra结尾。 - 阳性动词以
-initis结尾,阴性动词以-inites结尾。 - 因此,佩佳语中每个单词的结尾必为上述六种之一。佩佳语中不存在其他任何结尾形式。
- 整个单词可以仅由一个结尾构成。即,“lios”、“liala”、“etr”等单词均属于佩佳语。
- 佩佳语中不存在标点符号、时态、单复数形式或其他任何语言复杂性。
- 一个句子要么恰好是一个合法的佩佳语单词,要么恰好是一个“陈述句(statement)”。
所谓“陈述句”,是指满足以下两个条件的任意佩佳语单词序列:
- 陈述句中单词从左至右的顺序必须为:零个或多个形容词,后接恰好一个名词,再后接零个或多个动词。
- 陈述句中所有单词的性别必须相同。
在佩佳的朋友瓦夏开发了一款支持佩佳语的即时通讯软件后,佩佳希望为该软件添加拼写与语法检查功能。由于瓦夏当时正在乡下,而佩佳又不愿久等,于是他请你来帮忙解决这一问题。你的任务是:给定一个单词序列,判断它是否恰好构成佩佳语中的一个合法句子。
输入格式
The first line contains one or more words consisting of lowercase Latin letters. The overall number of characters (including letters and spaces) does not exceed 105.
It is guaranteed that any two consecutive words are separated by exactly one space and the input data do not contain any other spaces. It is possible that given words do not belong to the Petya's language.
第一行包含一个或多个由小写拉丁字母组成的单词。字符总数(包括字母和空格)不超过 105。
保证任意两个相邻单词之间恰好有一个空格,且输入数据中不包含其他任何空格。给定的单词可能不属于佩蒂亚的语言。
输出格式
If some word of the given text does not belong to the Petya's language or if the text contains more that one sentence, print "NO" (without the quotes). Otherwise, print "YES" (without the quotes).
如果给定文本中的某个单词不属于佩蒂亚的语言,或者文本包含超过一个句子,则输出 "NO"(不带引号)。否则,输出 "YES"(不带引号)。
输入输出样例
输入#1
petr
输出#1
YES
输入#2
etis atis animatis etis atis amatis
输出#2
NO
输入#3
nataliala kataliala vetra feinites
输出#3
YES
输入解题思路,AI测评打分。不知道怎么写?