#K84682. ABC Removal Challenge
ABC Removal Challenge
ABC Removal Challenge
You are given a string ( s ) and an integer ( n ) representing its length (although ( n ) may not be directly needed in your solution). Your task is to determine whether it is possible to make the string empty by repeatedly removing occurrences of the substring ( abc ). In one operation, you may remove a single occurrence of ( abc ) from the string. If after a sequence of such operations the string becomes empty, print YES
, otherwise print NO
.
For instance, if ( s = \texttt{abcabc} ), you can remove one occurrence of ( abc ) (either the first or the second occurrence) and then remove the remaining ( abc ) to end up with an empty string.
inputFormat
The input consists of two lines. The first line contains an integer ( n ), the length of the string. The second line contains the string ( s ) composed of lowercase English letters.
outputFormat
Output a single line containing YES
if it is possible to reduce the string to empty by repeatedly removing occurrences of ( abc ), or NO
otherwise.## sample
6
abccba
NO