Codeforces Round #498 (Div. 3) D. Two Strings Swaps

---恢复内容开始---

D. Two Strings Swaps
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

You are given two strings aa and bb consisting of lowercase English letters, both of length nn. The characters of both strings have indices from 11 to nn, inclusive.

You are allowed to do the following changes:

  • Choose any index ii (1in1≤i≤n) and swap characters aiai and bibi;
  • Choose any index ii (1in1≤i≤n) and swap characters aiai and ani+1an−i+1;
  • Choose any index ii (1in1≤i≤n) and swap characters bibi and bni+1bn−i+1.

Note that if nn is odd, you are formally allowed to swap an2a⌈n2⌉ with an2a⌈n2⌉ (and the same with the string bb) 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 aa with another character. In other words, in a single preprocess move you can choose any index ii (1in1≤i≤n), any character cc and set ai:=cai:=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 aa and bb 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 movesto the string bb or make any preprocess moves after the first change is made.

Input

The first line of the input contains one integer nn (1n1051≤n≤105) — the length of strings aa and bb.

The second line contains the string aa consisting of exactly nn lowercase English letters.

The third line contains the string bb consisting of exactly nn lowercase English letters.

Output

Print a single integer — the minimum number of preprocess moves to apply before changes, so that it is possible to make the string aa equal to string bb with a sequence of changes from the list above.

Examples
input
Copy
7
abacaba
bacabaa
output
Copy
4
input
Copy
5
zcabd
dbacz
output
Cop 0


分类讨论太菜了....蛮水的一道题



1 利用Map <char,int> 记录当前位置的字符种类,
1这种情况肯定不用说了
2 这种情况数量可能是 1 3 那么时候利用mp[s[i]]==2就可以判断是不是 1 3
3 这种情况是 1 1 2 这种情况
这种又分两种情况 那么就是 那么2 实在s1[]还是在 s2[], 由题意我们可以知道 只能改变s1[]来确保工作可以完成 因此如果2在s1[]的话,我们需要多加ans+=2;
4 ans+=2;

---恢复内容结束--

posted @ 2018-07-20 22:14  Xzavieru  阅读(284)  评论(0)    收藏  举报