300590: CF113A. Grammar Lessons
Memory Limit:256 MB
Time Limit:5 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Grammar Lessons
题意翻译
### 题目描述 Petya 发明了一种语言。这种语言的词有三种词性、两种性别。下面是每一种词性和性别的结尾表格: | |阳性|阴性| |---|---|---| |形容词|-lios|-liala| |名词|-etr|-etra| |动词|-initis|-inites| 这种语言的语法有以下几条: 1. 每个句子必须按照以下顺序书写:$0$ 个或多个形容词、$1$ 个名词、$0$ 个或多个动词。 2. 一个句子中所有单词的性别必须相同。 3. 每一个单词都以上述结尾来结尾,也就是说,不以上述的结尾来结尾的单词不符合语法。 4. **单独一个合法单词也可以组成一个合法的句子。** 现在 Petya 需要你来帮助他检查语法,如果正确输出 `YES`,否则输出 `NO`。 ### 输入格式 一行,一个包含若干以空格分隔的单词的字符串 $s$。($\lvert s \lvert \leq 10^5$) 数据保证单词仅由小写字母组成,单词间有且只有一个空格。 ### 输出格式 一行,`YES` 或 `NO`。题目描述
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.输入输出格式
输入格式
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 $ 10^{5} $ . 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.
输出格式
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).
输入输出样例
输入样例 #1
petr
输出样例 #1
YES
输入样例 #2
etis atis animatis etis atis amatis
输出样例 #2
NO
输入样例 #3
nataliala kataliala vetra feinites
输出样例 #3
YES