113A.md (2924B)
1 Source: https://codeforces.com/problemset/problem/113/A 2 3 A. Grammar Lessons 4 5 time limit per test 6 7 5 seconds 8 9 memory limit per test 10 11 256 megabytes 12 13 input 14 15 stdin 16 17 output 18 19 stdout 20 21 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: 22 23 * There are three parts of speech: the adjective, the noun, the verb. Each word in his language is an adjective, noun or verb. 24 * There are two genders: masculine and feminine. Each word in his language has gender either masculine or feminine. 25 * Masculine adjectives end with -lios, and feminine adjectives end with -liala. 26 * Masculine nouns end with -etr, and feminime nouns end with -etra. 27 * Masculine verbs end with -initis, and feminime verbs end with -inites. 28 * 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. 29 * 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. 30 * There aren't any punctuation marks, grammatical tenses, singular/plural forms or other language complications. 31 * A sentence is either exactly one valid language word or exactly one statement. 32 33 Statement is any sequence of the Petya's language, that satisfy both conditions: 34 35 * 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. 36 * All words in the statement should have the same gender. 37 38 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. 39 40 Input 41 42 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. 43 44 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. 45 46 Output 47 48 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). 49 50 Examples 51 52 Input 53 54 ``` 55 petr 56 ``` 57 58 Output 59 60 ``` 61 YES 62 ``` 63 64 Input 65 66 ``` 67 etis atis animatis etis atis amatis 68 ``` 69 70 Output 71 72 ``` 73 NO 74 ``` 75 76 Input 77 78 ``` 79 nataliala kataliala vetra feinites 80 ``` 81 82 Output 83 84 ``` 85 YES 86 ```