#P3531. [POI 2012] LIT-Letters
[POI 2012] LIT-Letters
Description
Given two strings , of equal length, each consisting only of uppercase letters, you may swap two adjacent characters in at a time. Find the minimum number of swaps needed so that the string obtained from becomes identical to .
Input Format
The first line contains an integer , the length of the strings.
The second line contains a string of length , denoting .
The third line contains a string of length , denoting .
Output Format
Output a single integer on one line, the minimum number of swaps.
3
ABC
BCA
2
Hint
Constraints
- For 30% of the testdata, it is guaranteed that .
- For 100% of the testdata, , , contain only uppercase letters, and the testdata guarantees that can be transformed into .
Translated by ChatGPT 5
京公网安备 11011102002149号