【链接】 我是链接,点我呀:)

【题意】

题意

【题解】

注意只能改变a不能改变b
然后只要让a[i],b[i],a[n-i-1],b[n-i-1]这4个字符能凑成两对、全都一样就可以了
分类讨论下就好

【代码】

#include <bits/stdc++.h>
#define ll long long
using namespace std; const int N = 300; int n;
string s1,s2;
map<char,int> dic,dic1; int main(){
ios::sync_with_stdio(0),cin.tie(0);
cin >> n;
cin >> s1;
cin >> s2;
int cnt = 0;
for (int i = 0;i < n/2;i++){
dic.clear();dic1.clear();
dic[s1[i]]++;
dic[s1[n-i-1]]++; dic1[s2[i]]++;
dic1[s2[n-i-1]]++;
int k1 = dic.size(),k2 = dic1.size();
if (k1==1 && k2==1){
cnt+=0;
}
if (k1==1 && k2==2){
dic1[s1[i]] = 1;
int t = dic1.size();
if (t==k2){
cnt++;
}else cnt+=2;
}
if (k1==2 && k2==1){
dic[s2[i]] = 1;
cnt++;
}
if (k1==2 && k2==2){
dic[s2[i]] = 1;
dic[s2[n-i-1]] = 1;
int t = dic.size();
if (t>k1+1){
cnt+=2;
}else if (t>k1){
cnt++;
}else cnt+=0;
}
}
if (n%2==1){
if (s1[n/2]!=s2[n/2]){
cnt++;
}
}
cout<<cnt<<endl;
return 0;
}

【Codeforces 1006D】Two Strings Swaps的更多相关文章

  1. 【24.34%】【codeforces 560D】Equivalent Strings

    time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  2. 【codeforces 415D】Mashmokh and ACM(普通dp)

    [codeforces 415D]Mashmokh and ACM 题意:美丽数列定义:对于数列中的每一个i都满足:arr[i+1]%arr[i]==0 输入n,k(1<=n,k<=200 ...

  3. 【codeforces 798B】Mike and strings

    [题目链接]:http://codeforces.com/contest/798/problem/B [题意] 给你n个字符串; 每次操作,你可以把字符串的每个元素整体左移(最左边那个字符跑到最后面去 ...

  4. 【52.49%】【codeforces 556A】Case of the Zeros and Ones

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

  5. 【19.46%】【codeforces 551B】ZgukistringZ

    time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  6. 【codeforces 755B】PolandBall and Game

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

  7. 【codeforces 750E】New Year and Old Subsequence

    time limit per test3 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  8. 【codeforces 761C】Dasha and Password(动态规划做法)

    time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  9. 【codeforces 761C】Dasha and Password(贪心+枚举做法)

    time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

随机推荐

  1. bzoj 4909 [Sdoi2017]龙与地下城

    题面 https://www.lydsy.com/JudgeOnline/problem.php?id=4909 题解 目前为止仅仅在LOJ上A掉这道题(Loj真快!) 当然不是标准做法 显然我们只要 ...

  2. 双端队列 HDOJ 3530 Subsequence

    题目传送门 题意:问最长子序列,满足区间最大值 - 最小值在[m, k]之间 分析:用双端队列维护最大值和最小值,保存的是位置.当满足条件时,更新最大值. /********************* ...

  3. What's mean ORA-25191?

    1.在给表授权的时候.报错ORA-25191 检查该表为IOT 表 . --因为不是按照单表方式授予权限,而是按照用户的方式授予权限,所以该表的父亲表都在该用户下,所以这个报错可以忽略. 2/ 在参考 ...

  4. 482 License Key Formatting 注册码格式化

    详见:https://leetcode.com/problems/license-key-formatting/description/ C++: class Solution { public: s ...

  5. Java 中 i++和++i的区别

    public class Test{ public static void main(String [] args){ int i = 1; int s = ++i; int x= i++; Syst ...

  6. AndroidStudio中使用SVN

    AndroidStudio中使用SVN提交项目 1.安装SVN,我选择使用TortoiseSVN-1.8.7.25475-x64-svn-1.8.9.msi(安装文件地址如下:http://downl ...

  7. Eclipse 闪退/无法启动/一闪而过打解决办法

    解决方法 删除文件:/.metadata/.plugins/org.eclipse.e4.workbench/workbench.xmi 经过实际应用真实有效.

  8. Android获取本地相册图片、拍照获取图片

    需求:从本地相册找图片,或通过调用系统相机拍照得到图片. 容易出错的地方: 1,当我们指定了照片的uri路径,我们就不能通过data.getData();来获取uri,而应该直接拿到uri(用全局变量 ...

  9. 实战角度比较EJB2和EJB3的架构异同

    ] EJB编程模型的简化 首先,EJB3简化的一个主要表现是:在EJB3中,一个EJB不再象EJB2中需要两个接口一个Bean实现类,虽然我们以前使用JBuilder这样可视化开发工具自动生成了EJB ...

  10. 借助tween.js小球沿div四边跑的动画效果

    <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <m ...