#B4048. Rightmost 'not' Removal Rounds

    ID: 11705 Type: Default 1000ms 256MiB

Rightmost 'not' Removal Rounds

Rightmost 'not' Removal Rounds

Given a string \(S\) consisting only of uppercase and lowercase letters (with indices starting at 1), process the string in rounds as follows:

  • In each round, locate the rightmost occurrence of the substring \(\texttt{not}\) in \(S\) (the search is case‐sensitive).
  • If such an occurrence exists, remove that exact substring (i.e. delete those 3 characters) from \(S\) and increment the round counter by 1.
  • Repeat the process with the new string until no occurrence of \(\texttt{not}\) remains.

Finally, output the resulting string and the total number of rounds applied.

Note: A substring is defined by choosing a pair of indices \(1 \le l \le r \le |S|\) and concatenating \(S_l, S_{l+1}, \ldots, S_r\). All indices are 1-indexed.

Example:

Input:  IcannototnAKIOI
Round 1: The rightmost "not" is found starting at index 7. Removing it yields: IcanotnAKIOI
Round 2: Now, in "IcanotnAKIOI", the rightmost "not" is found starting at index 4. Removing it yields: IcanAKIOI

Output: IcanAKIOI 2

</p>

inputFormat

The input consists of a single line containing the string \(S\) (with at least one character and no spaces).

outputFormat

Output two lines:

  • The first line should be the final string after all rounds of removals.
  • The second line should be the total number of rounds performed.

sample

IcannototnAKIOI
IcanAKIOI

2

</p>