ABC Gene
Time limit2sMemory limit512 MB
Starting from "ABC", repeatedly replace every occurrence of one chosen letter with "ABC"; decide whether a given string can be produced.
- Level
Medium7 of 10
- Topics
- String, Greedy, Divide and conquer, Recursion
- Solved
- No attempts yet
Problem
There is a gene sequence represented by the string ABC. You may perform the following operation any number of times to rewrite this gene sequence.
- Choose one of the characters
A,B, andC. Call it . Simultaneously replace every contained in the gene sequence withABC.
You are given a string consisting only of A, B, and C. Determine whether the gene sequence can be made to match .
Input
The input is given from standard input in the following format.
Output
If the gene sequence can be made to match , print Yes; otherwise, print No on a single line.
Constraints
- consists only of
A,B, andC.