【Codeforces 1006D】Two Strings Swaps
【链接】 我是链接,点我呀:)
【题意】
题意
【题解】
注意只能改变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的更多相关文章
- 【24.34%】【codeforces 560D】Equivalent Strings
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...
- 【codeforces 415D】Mashmokh and ACM(普通dp)
[codeforces 415D]Mashmokh and ACM 题意:美丽数列定义:对于数列中的每一个i都满足:arr[i+1]%arr[i]==0 输入n,k(1<=n,k<=200 ...
- 【codeforces 798B】Mike and strings
[题目链接]:http://codeforces.com/contest/798/problem/B [题意] 给你n个字符串; 每次操作,你可以把字符串的每个元素整体左移(最左边那个字符跑到最后面去 ...
- 【52.49%】【codeforces 556A】Case of the Zeros and Ones
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...
- 【19.46%】【codeforces 551B】ZgukistringZ
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...
- 【codeforces 755B】PolandBall and Game
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...
- 【codeforces 750E】New Year and Old Subsequence
time limit per test3 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...
- 【codeforces 761C】Dasha and Password(动态规划做法)
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...
- 【codeforces 761C】Dasha and Password(贪心+枚举做法)
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...
随机推荐
- scikit-learning教程(三)使用文本数据
使用文本数据 本指南的目标是探讨scikit-learn 一个实际任务中的一些主要工具:分析二十个不同主题的文本文档(新闻组帖子)集合. 在本节中,我们将看到如何: 加载文件内容和类别 提取适用于机器 ...
- 洛谷p1955[NOI2015]程序自动分析
题目: 在实现程序自动分析的过程中,常常需要判定一些约束条件是否能被同时满足. 考虑一个约束满足问题的简化版本:假设x1,x2,x3...代表程序中出现的变量,给定n个形如xi=xj或xi≠xj的变量 ...
- 152 Maximum Product Subarray 乘积最大子序列
找出一个序列中乘积最大的连续子序列(该序列至少包含一个数).例如, 给定序列 [2,3,-2,4],其中乘积最大的子序列为 [2,3] 其乘积为 6.详见:https://leetcode.com/p ...
- 135 Candy 分配糖果
There are N children standing in a line. Each child is assigned a rating value.You are giving candie ...
- 用NPOI从DataTable到Excel,向Excel模板填充数据
DataTable---->Excel,填充数据 private IWorkbook workbook = null; private ISheet sheet = null; private ...
- vue中引入字体图标报错,找不到字体文件
在用vue + webpack进行开发的时候,在引用字体图标遇到字体无法加载的问题: 报以下错误 搞了好久没搞定,最后才找到解决方法(还是没有找到原因) 修改字体图标的css中引入字体文件的路径 以前 ...
- docker最新版本以及docker-compose安装脚本
docker最新版本以及docker-compose编排工具安装脚本 git clone https://github.com/luckman666/shell_scripts.git cd shel ...
- 项目中常用git命令操作指令(一般正常的话够用不够再看相关git命令)
配置git1.首先在本地创建ssh key:ssh-keygen -t rsa -C "github上注册的邮箱" //(一路回车)2.进入c:/Users/xxxx_000/.s ...
- umask命令
umask——显示.设置文件的缺省权限 the user file-creation mask 命令所在路径:Shell内置命令 示例1:显示缺省权限 # umask -S 参数S的作用是以rwx形式 ...
- mysql中的 enum (枚举)
mysql enum是指字段的类型 表示枚举类型 mysql> alter table student add adders enum("sichuang","sh ...