MNYC '16: Abdoof

View as PDF

Submit solution

Points: 7
Time limit: 1.0s
Memory limit: 256M

Author:
Problem type

Abdul has created a naming convention for places (countries, cities, streets, etc.). Words are composed of sections. There are three valid types of sections: A, B and C. The following elements are categorized into section A: ch, t, m, d, b, bd, r. The following elements are categorized into section B: a, e, i, oo. Finally, the following elements are categorized into section C: n, v, f. Valid words are composed of sections that follow strict placement rules. A word may start with either section A or B. A word must be at least 2 sections in length. A word cannot have two consecutive sections of the same type. A word must end with either section A or C. Section C can only end a word, and thus not exist anywhere else. A name consists of two or more words. The case is not relevant.

Given a name, check whether or not it is a valid name, according to the naming convention explained above. If it is valid, output valid otherwise, output invalid.

Input Specification

A single line with a name containing 1 \le W \le 100 words. Each word has 1 \le L \le 200 letters.

Output Specification

valid or invalid depending on whether the name given was a valid or invalid name according to Abdul's naming convention.

Sample Input 1

Abdoof Arif

Sample Output 1

valid

Sample Input 2

Abdul

Sample Output 2

invalid

Explanation for Sample Output 2

First of all, the word Abdul is not a valid word. Secondly, there is only 1 word in the name.


Comments


  • 0
    richardyi25  commented on April 19, 2016, 1:13 a.m. edited

    Can you add the number of words W as the first line so it is solvable in Turing?


    • 1
      aurpine  commented on April 19, 2016, 1:22 a.m. edit 3

      Considering that so many users have already solved the problem, it would be too much of a hassle to change the format of the input (many AC solutions would then become WA on the new test data). However, you can read in each word separately and have a counter etc. Use exit when eof to read until the end of input. See here for more details. (scroll down)


      • 2
        richardyi25  commented on April 19, 2016, 2:44 a.m. edited

        Thanks for responding and informing me about eof!


  • 0
    Anix55  commented on Feb. 24, 2016, 11:11 p.m. edited

    should our program be case sensitive?


    • 0
      Zander  commented on Feb. 24, 2016, 11:23 p.m. edited

      the case doesn't matter


      • 0
        Anix55  commented on Feb. 24, 2016, 11:25 p.m. edited

        thanks