Shuffle
면접 대비시간 제한2초메모리 제한512 MB
길이가 같고 짝수인 두 문자열 s와 t가 주어질 때, 홀수 위치 문자를 앞으로 모으는 shuffle 연산을 최소 몇 번 적용해야 t가 되는지 구하고, 불가능하면 -1을 출력한다.
문제
Given a string of even length , we define operation which transforms a string into a new string according to the following rule:
For example, .
You are given two strings of equal even length, and . How many times do you have to apply shuffle operation to in order to get as a result?
In the other words, find minimum such that or report that it is not possible to reach in any number of operations.
입력
The first line of input contains a string , the second contains a string (, , is even). Both strings consist of lowercase English characters.
출력
Print minimum non-negative such that it is possible to obtain from by applying shuffle operation times (or maybe not applying at all if ), or print -1 if it is impossible.