A finite state machine (sometimes called a finite state automaton) is a computation model that can be implemented with hardware or software and can be used to simulate sequential logic and some computer programs.
For more information read https://en.wikipedia.org/wiki/Finite-state_machine
‘A’ is starting state, ‘E’ and ‘C’ and accepting states.
You are given a String and check whether the above FSM accepts the string.
Example:
S=”abaa”
(A,”abaa”)->(B,”baa”)->(E,”aa”)->(B,”a”)->C
As ‘C’ is accepting state, string S is accepted by the above FSM.
Input format
Output format
For each test case, prints YES or NO whether the string is accepted by FSM
Constraints
1<=N<=1000
1<=LEN(S)<=10000