题库练习 Reverses
← 上一题 下一题 →

A11554 | Reverses

时间限制1s
内存限制256MB
通过 / 提交0/0

题目描述

Hurricane came to Berland and to suburbs Stringsvill. You are going to it to check if it's all right with you favorite string. Hurrinace broke it a bit by reversing some of its non-intersecting substrings. You have a photo of this string before hurricane and you want to restore it to original state using reversing minimum possible number of its substrings and find out which substrings you should reverse.

You are given a string $s$ — original state of your string and string $t$ — state of the string after hurricane. You should select $k$ non-intersecting substrings of $t$ in such a way that after reverse of these substrings string will be equal $s$ and $k$ is minimum possible.

输入格式

First line of input contains string $s$ and second line contains string $t$ . Both strings have same length and consist of lowercase English letters. $1<=|s|=|t|<=5·10^{5}$

输出格式

In first line print $k$ — minimum number of substrings you should reverse. Next output $k$ lines. Each line should contain two integers $l_{i}$ , $r_{i}$ meaning that you should reverse substring from symbol number $l_{i}$ to symbol $r_{i}$ (strings are 1-indexed). These substrings shouldn't intersect. If there are multiple answers print any. If it's impossible to restore string output -1.

输入输出样例

输入 #1
abcxxxdef
cbaxxxfed
输出 #1
2
7 9
1 3
C++ 编辑器
输入
输出