CF1006D.Two Strings Swaps
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are given two strings a and b consisting of lowercase English letters, both of length n . The characters of both strings have indices from 1 to n , inclusive.
You are allowed to do the following changes:
- Choose any index i ( 1≤i≤n ) and swap characters ai and bi ;
- Choose any index i ( 1≤i≤n ) and swap characters ai and an−i+1 ;
- Choose any index i ( 1≤i≤n ) and swap characters bi and bn−i+1 .
Note that if n is odd, you are formally allowed to swap a⌈2n⌉ with a⌈2n⌉ (and the same with the string b ) but this move is useless. Also you can swap two equal characters but this operation is useless as well.
You have to make these strings equal by applying any number of changes described above, in any order. But it is obvious that it may be impossible to make two strings equal by these swaps.
In one preprocess move you can replace a character in a with another character. In other words, in a single preprocess move you can choose any index i ( 1≤i≤n ), any character c and set ai:=c .
Your task is to find the minimum number of preprocess moves to apply in such a way that after them you can make strings a and b equal by applying some number of changes described in the list above.
Note that the number of changes you make after the preprocess moves does not matter. Also note that you cannot apply preprocess moves to the string b or make any preprocess moves after the first change is made.
输入格式
The first line of the input contains one integer n ( 1≤n≤105 ) — the length of strings a and b .
The second line contains the string a consisting of exactly n lowercase English letters.
The third line contains the string b consisting of exactly n lowercase English letters.
输出格式
Print a single integer — the minimum number of preprocess moves to apply before changes, so that it is possible to make the string a equal to string b with a sequence of changes from the list above.
输入输出样例
输入#1
7 abacaba bacabaa
输出#1
4
输入#2
5 zcabd dbacz
输出#2
0
说明/提示
In the first example preprocess moves are as follows: $a_1 := $ 'b', $a_3 := $ 'c', $a_4 := $ 'a' and a5:= 'b'. Afterwards, $a = $ "bbcabba". Then we can obtain equal strings by the following sequence of changes: swap(a2,b2) and swap(a2,a6) . There is no way to use fewer than 4 preprocess moves before a sequence of changes to make string equal, so the answer in this example is 4 .
In the second example no preprocess moves are required. We can use the following sequence of changes to make a and b equal: swap(b1,b5) , swap(a2,a4) .