Official

F - I prefer ISCT Editorial by x0214sh7


The basic idea is to greedily replace the substrings of TIOT in \(S\) with ISCT, but when performing operations on a segment of TIOTIO...TIOT, you must pay attention to the order. To address this, let us consider the inverse of the operation.

  • Inverse operation: Select a substring in \(T\) that is ISCT and replace it with TIOT.

Thus, the problem becomes “Can you make \(T\) equal to \(S\) by performing the inverse operation?” This can be determined by greedily applying the inverse operation from the back.

posted:
last update: