Corona Virus Spread
Indeed, this task as well is about coronavirus :D.
In our simulator, we will represent the population by a string of lowercase characters. Also, we represent infected people with a lowercase character 'c'.
All initially infected people (the c's) will then start infecting the other character, and any infected character will die instantly (except those initially infected). However, the c's will only infect those to their left one a day, and of course, cannot infect an already infected person (another character c). This goes on every day until there is no other person is infected and dead.
Your task is, given a string of lowercase characters that represent the initial population of our simulator, find the number of days until no other person is infected, and the representation of our population after the end of the virus spread.
The first line of the input contains \(1 \le T \le 10\), the number of test cases.
T lines follow, each contains a string \(1 \le |s| \le 100\) with lower case letters, where |s| denotes the length of the string s.
For each test case, output the number of days until the virus will no longer spread followed by the representation of our population after the virus stops spreading.
5 azuz corona anoroc stopcorona stopcocorona
0 azuz 0 corona 5 c 4 corona 4 ccorona
- In the 1st sample, nobody is infected initially.
- In the 2nd sample, only the first person is infected, thus the virus will not spread to any other person.
- In the 3d sample, the last person is infected
- In the 4rd sample, the c right after stop will eat all the 4 letters before it.
- In the 5th sample, in the first day the leftmost c will eat p and the second one will eat o. Then the left c will eat the remaining characters of stop in the remaining 3 days.