CF1012D.AB-Strings

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

There are two strings ss and tt , consisting only of letters a and b. You can make the following operation several times: choose a prefix of ss , a prefix of tt and swap them. Prefixes can be empty, also a prefix can coincide with a whole string.

Your task is to find a sequence of operations after which one of the strings consists only of a letters and the other consists only of b letters. The number of operations should be minimized.

输入格式

The first line contains a string ss ( 1<=s<=21051<=|s|<=2·10^{5} ).

The second line contains a string tt ( 1<=t<=21051<=|t|<=2·10^{5} ).

Here s|s| and t|t| denote the lengths of ss and tt , respectively. It is guaranteed that at least one of the strings contains at least one a letter and at least one of the strings contains at least one b letter.

输出格式

The first line should contain a single integer nn ( 0<=n<=51050<=n<=5·10^{5} ) — the number of operations.

Each of the next nn lines should contain two space-separated integers aia_{i} , bib_{i} — the lengths of prefixes of ss and tt to swap, respectively.

If there are multiple possible solutions, you can print any of them. It's guaranteed that a solution with given constraints exists.

输入输出样例

  • 输入#1

    bab
    bb
    

    输出#1

    2
    1 0
    1 3
    
  • 输入#2

    bbbb
    aaa
    

    输出#2

    0
    

说明/提示

In the first example, you can solve the problem in two operations:

  1. Swap the prefix of the first string with length 11 and the prefix of the second string with length 00 . After this swap, you'll have strings ab and bbb.
  2. Swap the prefix of the first string with length 11 and the prefix of the second string with length 33 . After this swap, you'll have strings bbbb and a.

In the second example, the strings are already appropriate, so no operations are needed.

首页