Burdochvirus Vaccine
Limits: 2 sec., 256 MiB
This statement was translated automatically from Ukrainian.
To produce a vaccine against the burdochvirus, immunologists only need to learn how to correctly transform the genetic sequence of the burdochvirus. The genetic sequence of the burdochvirus is a string \(s\) of length \(n\) consisting of lowercase Latin letters. To successfully create the vaccine, it must be transformed into a string \(t\), which also consists of \(n\) lowercase Latin letters. In one operation, you are allowed to move one character of the current genetic sequence to its end.
Your task is to learn how to transform the initial genetic sequence \(s\) into the required sequence \(t\). The transformation must be sufficiently efficient, so you are allowed to use no more than \(n\) operations.
Input
The first line gives the string \(s\).
The second line gives the string \(t\).
Output
In the first line, print a single natural number \(k\) (\(1 \le k \le n\)) — the number of operations.
In the next line, print \(k\) natural numbers \(x_i\) (\(1 \le x_i \le n\)) — the operations in the order they need to be performed.
A sequence of operations that transforms string \(s\) into string \(t\) in no more than \(n\) operations is guaranteed to exist. If there is more than one such sequence of operations, you are allowed to output any of them. Note that there is no need to minimize the number of operations in the sequence. It is sufficient that this number is no greater than \(n\).
Constraints
\(s \ne t\),
the string \(s\) contains the same multiset of characters as \(t\),
5 tests: \(2 \le n \le 7\),
15 tests: \(2 \le n \le 1000\),
25 tests: \(2 \le n \le 10^5\).
Samples
| Input (stdin) | Output (stdout) |
|---|---|
| abxy axby | 2 2 3 |
| Input (stdin) | Output (stdout) |
|---|---|
| abaacd abcdaa | 6 3 2 3 3 3 1 |
Notes
In the first test, the initial genetic sequence has the following
form: abxy. By the first operation, we move the second
character to the end and the sequence becomes axyb. By the
second operation, we move the third character to the end and the
sequence becomes axby, which is the required sequence.
Submit a solution
| Element Type | Created | Who | Problem | Compiler | Result | Time (sec.) | Memory (MiB) | # | Actions |
|---|
| Element Type | Created | Who | Problem | Compiler | Result | Time (sec.) | Memory (MiB) | # | Actions |
|---|