CF1370E Binary Subsequence Rotation
题目描述
给定两个长度为$n$的$01$串$a$和$b$,要求串$a$的任意子序列经过若干次“旋转”操作变为串$b$
对于一次“旋转操作”我们这样定义:
如果我们要旋转的序列为
$c_1,c_2,c_3,c_4,c_5...c_n$
那么旋转之后的序列为$c_n,c_1,c_2,c_3,c_4...c_{n-1}$
例如对于$s=1110100$
如果我们旋转的子序列的下标为${2,6,7}$(从1开始)
那么旋转之后的串为$1010110 $
求至少进行多少次“旋转”操作,能够把串$a$变成串$b$
输入格式
输入一共三行
第一行输入一个整数$n(1≤n≤10^6)$
第二行输入串$a$
第三行输入串$b$
输出格式
输出为$1$行,为最小的操作次数
说明/提示
In the first test, Naman can choose the subsequence corresponding to indices $ \{2, 6\} $ and rotate it once to convert $ s $ into $ t $ .
In the second test, he can rotate the subsequence corresponding to all indices $ 5 $ times. It can be proved, that it is the minimum required number of operations.
In the last test, it is impossible to convert $ s $ into $ t $ .