Game with Strings
Limits: 2 sec., 256 MiB
Today Zenyk and Marichka have a game night, and they decided to play
the following interesting game. Marichka writes down on two long pieces
of paper strings \(s\) and \(t\), which consist of characters
A
and B
. The goal for Zenyk is to cut out
exactly \(|t|\) characters from \(s\) in such a way that the following two
conditions are fulfilled:
The cut out characters make up string \(t\), if placed in the same order as in \(s\).
The remaining parts of \(s\) must be of form
AA..A
orBB..B
. In other words, there should be no part that contains bothA
andB
at the same time.
You are given two string \(s\) and \(t\). Help Zenyk achieve the goal of the game.
Input
The first line contains string \(s\), and the second line contains string
\(t\). Both strings consist only of
A
and B
characters.
Output
On the first line print "YES"
if it is possible to
achieve the goal, and "NO"
otherwise (without quotes). In
case of a positive answer, on the next line print \(|t|\) distinct integers in increasing
order, which are the positions of characters that Zenyk will cut out
from \(s\) (1-based index). If multiple
answers exit, you may print any one of them.
Constraints
\(1 \le |t| \le |s| \le 10^5\).
Samples
Input (stdin) | Output (stdout) |
---|---|
AABBBAABBBABBB ABBA | YES 2 5 8 11 |
Input (stdin) | Output (stdout) |
---|---|
ABABABAB ABBA | NO |
Notes
In the first sample, after cutting out the given characters, the
following parts are left out: A
, BB
,
AA
, BB
, BBB
. None of them contain
both A
and B
at the same time.
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 |
---|