CF1012D AB-Strings
题目描述
## 题面描述
给定两个只包含 $\texttt{a}$ 和 $\texttt{b}$ 的字符串,每次操作可以把两个字符串的任意前缀进行交换(前缀长度可以为 $0$),问最少多少次操作可以使的一个串只有 $\texttt{a}$,另一个串只有 $\texttt{b}$。
输入格式
两行,一行一个字符串,保证串长 $\leq 200000$。
保证两个串中有 $\texttt{a}$ 和 $\texttt{b}$。
输出格式
第一行一个整数 $n(0\leq n\leq 500000)$,表示答案。
后面 $n$ 行,一行两个整数,表示每次操作时被交换的两个串的前缀长度。
说明/提示
In the first example, you can solve the problem in two operations:
1. Swap the prefix of the first string with length $ 1 $ and the prefix of the second string with length $ 0 $ . After this swap, you'll have strings ab and bbb.
2. Swap the prefix of the first string with length $ 1 $ and the prefix of the second string with length $ 3 $ . After this swap, you'll have strings bbbb and a.
In the second example, the strings are already appropriate, so no operations are needed.