Chromosome
InterviewTime limit2sMemory limit64 MB
Decide for each uppercase string whether it matches an optional A-to-F letter followed by runs of A, F, and C and an optional closing letter.
- Level
Easy3 of 10
- Topics
- String matching, String
- Solved
- No attempts yet
Problem
Sanggeun works at a life science lab and checks whether a chromosome follows one specific pattern. A chromosome is a string made only of uppercase letters (A, B, C, ..., Z). He has to test every chromosome against all of the rules below.
- The string begins with one letter from {A, B, C, D, E, F}, or with no letter at all.
- Then comes one or more A.
- Then comes one or more F.
- Then comes one or more C.
- Then comes one letter from {A, B, C, D, E, F} or no letter at all, and nothing may follow it.
Given a string, write a program that decides whether it follows these rules.
Input
The first line contains the number of test cases (). Each of the next lines contains one string made only of uppercase letters. Each string is at most 200 characters long.
Output
For each test case, print "Infected!" if the string follows the rules, and "Good" if it does not.