305315: CF1006D. Two Strings Swaps
Memory Limit:256 MB
Time Limit:2 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Two Strings Swaps
题意翻译
**题目大意:** 有两个长度为$n$的字符串a,b,现有三种操作 - 交换$a_i,b_i$ - 交换$a_i,a_{n-i+1}$ - 交换$b_i,b_{n-i+1}$ 可以发现$a$不一定能通过这些交换变成$b$ 现在你还有一种操作,在交换字符之前,你可以把$a$中某个位置字符变成任意一个字符 问要使$a==b$最少要用**操作四**多少次 **输入格式:** 第一行一个整数$n$ 第二行字符串$a$,第三行字符串$b$ **输出格式:** 一个整数,表示用操作四的最少次数题目描述
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 \le i \le n $ ) and swap characters $ a_i $ and $ b_i $ ; - Choose any index $ i $ ( $ 1 \le i \le n $ ) and swap characters $ a_i $ and $ a_{n - i + 1} $ ; - Choose any index $ i $ ( $ 1 \le i \le n $ ) and swap characters $ b_i $ and $ b_{n - i + 1} $ . Note that if $ n $ is odd, you are formally allowed to swap $ a_{\lceil\frac{n}{2}\rceil} $ with $ a_{\lceil\frac{n}{2}\rceil} $ (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 \le i \le n $ ), any character $ c $ and set $ a_i := 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 \le n \le 10^5 $ ) — 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