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:
Statement is any sequence of the Petya's language, that satisfy both conditions:
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.
InputThe 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.
OutputIf 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).
Sample test(s) inputpetroutput
YESinput
etis atis animatis etis atis amatisoutput
NOinput
nataliala kataliala vetra feinitesoutput
YES
應該是Div 1.有點麻煩。最初題意還看錯了sad 7次才過掉。
題意: 現在有3種詞,形容詞,名詞,動詞,每種詞有兩種詞性,每種詞性對應一種後綴,現在給出一個句子的定義:要求是有一個合法單詞或一個合法聲明。
合法單詞是指有一種上面的後綴;合法聲明定義為:含有0個以上的形容詞+一個名詞+0個以上的動詞(按形容詞名詞動詞的順序且所以的詞的詞性相同)
哎個判斷條件就是了。。很容易漏點
#include#include #include #include #include #include #include #include