#P9763. [ROIR 2021] 基因突变 (Day 1)

[ROIR 2021] 基因突变 (Day 1)

Background

Translated from ROIR 2021 Day 1 T3 Изменённая ДНК

Problem Description

We define that a valid gene string contains only A, G, C, and T.

We define that any valid gene string has a compressed string. The compressed string replaces each maximal consecutive block of the same letter in the original gene string with: the number of occurrences followed by that letter. If the number is 11, the number is omitted.

Example: the compressed string of AAAAACAAAAACC is 5AC5A2C.

Now you are given a valid gene string SS, whose compressed string is TT. You may perform exactly one operation on SS. The operation can be one of the following three types:

  • Insert a character ZZ after the xx-th character of SS.
  • Delete the xx-th character of SS.
  • Replace the xx-th character of SS with another character ZZ.

Let SS become SS' after the operation, and let the compressed string of SS' be TT'. Find one operation plan that minimizes the length of TT', and one operation plan that maximizes the length of TT'.

Input Format

One line containing a string TT.

Output Format

Output two lines in total. The first line is one plan that minimizes the length of TT'. The second line is one plan that maximizes the length of TT'.

The output format for a plan is as follows:

  • If you want to use operation 11, output in the form 1 x Z.
  • If you want to use operation 22, output in the form 2 x.
  • If you want to use operation 33, output in the form 3 x Z.
5AC5A2C
3 6 A
1 2 C

Hint

[Sample Explanation]:

S=S= AAAAACAAAAACC.

After applying operation 3 6 A, we have S=S'= AAAAAAAAAAACC, and T=T'= 11A2C.

After applying operation 1 2 C, we have S=S'= AACAAACAAAAACC, and T=T'= 2AC3AC5A2C.

[Constraints]:

For all subtasks, 1T1051\le |T|\le 10^5, 1S1091\le |S|\le 10^9.

Subtask ID Constraints Points
11 TS10\lvert T\rvert\le \lvert S\rvert\le 10 99
22 T100\lvert T\rvert\le 100, S104\lvert S\rvert\le 10^4 1717
33 T103\lvert T\rvert\le 10^3, S105\lvert S\rvert\le 10^5 2121
44 S107\lvert S\rvert\le 10^7 1111
55 No special constraints 4242

Translated by ChatGPT 5