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.
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++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted