Lavanya Loves DFA
All submissions for this problem are available.There are $5$ cities in the country. The map of the country is given below. The tour starts from the red city. Each road is associated with a character. Initially, there is an empty string. Every time a road has been travelled the character associated gets appended to the string. At the green city either the string can be printed or the tour can be continued. In the problem, you are given a string tell whether it is possible to print the string while following the rules of the country? ###Input: - First line will contain $T$, number of testcases. Then the testcases follow. - Each testcase contains a single line of input, a string $ s $. The string consists only of $0's$ and $1's$. ###Output: For each testcase, output "YES" or "NO" depending on the input. ###Constraints - $1 \leq T \leq 10000$ - $1 \leq length of each string \leq 10000$ - $ 1 \leq Summation length \leq 10^5$ ###Sample Input: 1 100 ###Sample Output: NO ###EXPLANATION:
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, rust, SCALA, swift, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, SQL, kotlin, PERL6, TEXT, CPP17, SCM chicken, PYP3, CLOJ, R, COB, FS|
Fetching successful submissions
If you are still having problems, see a sample solution here.