#Lutece1583. 曜酱的心意
曜酱的心意
Migrated from Lutece 1583 曜酱的心意
All parts of this problem, including description, images, samples, data and checker, might be broken. If you find bugs in this problem, please contact the admins.
Description
说希望和我一起做学园偶像的时候,我真的很开心。——
曜是千歌的青梅竹马,但是成立以后,千歌似乎总是与梨子在一起,而把曜冷落了。
为了让千歌知晓自己的心意,曜酱决定做一件大事!
她决定把一个给定的的排列(,且各不相同),
用最少的交换次数,变换成另一个的排列。并且,每次只交换相邻的两个元素。
也许这样做了以后,千歌能更多地注意自己吧。曜这样想。
Input
第一行是一个整数,
第二行是一个长度为的的排列,
第三行是另一个长度为的的排列。
Output
输出一行,一个整数,表示最少的交换次数。
Samples
4
2 3 1 4
3 2 1 4
1
3
3 2 1
1 2 3
3
Note
Resources
17暑假前集训-数据结构专题 By AutSky_JadeK - NOIP2014 提高组 火柴排队