Some dwarves that are finishing the StUDY (State University for Dwarven Youngsters) Bachelor courses, have been told "no genome, no degree". That means that all dwarves should write a thesis on genome. Dwarven genome is far from simple. It is represented by a string that consists of lowercase Latin letters.

Dwarf Misha has already chosen the subject for his thesis: determining by two dwarven genomes, whether they belong to the same race. Two dwarves belong to the same race if we can swap two characters in the first dwarf's genome and get the second dwarf's genome as a result. Help Dwarf Misha and find out whether two gnomes belong to the same race or not.

Input

The first line contains the first dwarf's genome: a non-empty string, consisting of lowercase Latin letters.

The second line contains the second dwarf's genome: a non-empty string, consisting of lowercase Latin letters.

The number of letters in each genome doesn't exceed 105. It is guaranteed that the strings that correspond to the genomes are different. The given genomes may have different length.

Output

Print "YES", if the dwarves belong to the same race. Otherwise, print "NO".

Examples

Input

ab
ba

Output

YES

Input

aa
ab

Output

NO

Note

  • First example: you can simply swap two letters in string "ab". So we get "ba".
  • Second example: we can't change string "aa" into string "ab", because "aa" does not contain letter "b".

题解:题目大意是让你判断是否能通过换两个字母的位置是否一样

代码:

#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm> using namespace std; int main()
{
char s1[100005],s2[100005];
scanf("%s%s",s1,s2);
int flag=0;
int a[100005];
int temp=0;
for(int t=0;t<strlen(s1);t++)
{ if(strlen(s1)!=strlen(s2))
{
flag=3;
}
if(s1[t]!=s2[t])
{
a[temp]=t;
temp++;
flag++;
if(flag==3)
break;
}
else
continue;
}
if(flag==2)
{
if(s1[a[0]]==s2[a[1]]&&s1[a[1]]==s2[a[0]])
{
printf("YES\n");
}
else
{
printf("NO\n");
}
}
else
{
printf("NO\n");
} return 0;
}

CodeForces - 186A-Comparing Strings的更多相关文章

  1. Codeforces 868D Huge Strings - 位运算 - 暴力

    You are given n strings s1, s2, ..., sn consisting of characters 0 and 1. m operations are performed ...

  2. codeforces 112APetya and Strings(字符串水题)

    A. Petya and Strings 点击打开题目 time limit per test 2 seconds memory limit per test 256 megabytes input ...

  3. [Codeforces Round #438][Codeforces 868D. Huge Strings]

    题目链接:868D - Huge Strings 题目大意:有\(n\)个字符串,\(m\)次操作,每次操作把两个字符串拼在一起,并询问这个新串的价值.定义一个新串的价值\(k\)为:最大的\(k\) ...

  4. [Educational Round 5][Codeforces 616F. Expensive Strings]

    这题调得我心疲力竭...Educational Round 5就过一段时间再发了_(:з」∠)_ 先后找了三份AC代码对拍,结果有两份都会在某些数据上出点问题...这场的数据有点水啊_(:з」∠)_[ ...

  5. Codeforces 559B - Equivalent Strings

    559B - Equivalent Strings 思路:字符串处理,分治 不要用substr(),会超时 AC代码: #include<bits/stdc++.h> #include&l ...

  6. Codeforces 112A-Petya and Strings(实现)

    A. Petya and Strings time limit per test 2 seconds memory limit per test 256 megabytes input standar ...

  7. CodeForces - 985F Isomorphic Strings

    假如两个区间的26的字母出现的位置集合分别是 A1,B1,A2,B2,....., 我们再能找到一个排列p[] 使得 A[i] = B[p[i]] ,那么就可以成功映射了. 显然集合可以直接hash, ...

  8. [Codeforces 452E] Three Strings

    [题目链接] https://codeforces.com/contest/452/problem/E [算法] 构建后缀数组 用并查集合并答案即可 时间复杂度 : O(NlogN) [代码] #in ...

  9. Codeforces 665C Simple Strings【暴力,贪心】

    题目链接: http://codeforces.com/contest/665/problem/C 题意: 改变最少的字符,使得最终序列无相同的连续的字符. 分析: 对每一个与前一个字符相同的字符,枚 ...

  10. Codeforces - 559B - Equivalent Strings - 分治

    http://codeforces.com/problemset/problem/559/B 这个题目,分治就好了,每次偶数层可以多一种判断方式,判断它的时间就是logn的(吧),注意奇数层并不是直接 ...

随机推荐

  1. ACM学习历程—POJ 3764 The xor-longest Path(xor && 字典树 && 贪心)

    题目链接:http://poj.org/problem?id=3764 题目大意是在树上求一条路径,使得xor和最大. 由于是在树上,所以两个结点之间应有唯一路径. 而xor(u, v) = xor( ...

  2. ACM学习历程—HDU 5073 Galaxy(数学)

    Description Good news for us: to release the financial pressure, the government started selling gala ...

  3. bzoj 1132: [POI2008]Tro 计算几何

    题目大意: 平面上有N个点. 求出所有以这N个点为顶点的三角形的面积和 N<=3000 题解 我们看到了n的范围,于是我们就知道这一定不是一个线性算法 所以我们尝试枚举三角形的一个点,那么我们现 ...

  4. BZOJ1720:[Usaco2006 Jan]Corral the Cows 奶牛围栏

    我对二分的理解:https://www.cnblogs.com/AKMer/p/9737477.html 题目传送门:https://www.lydsy.com/JudgeOnline/problem ...

  5. Poj 2602 Superlong sums(大数相加)

    一.Description The creators of a new programming language D++ have found out that whatever limit for ...

  6. JavaScript继承与聚合

    一,继承 第一种方式:类与被继承类直接耦合度高 1,首先,准备一个可以被继承的类(父类),例如 //创建一个人员类 function Person(name) {//现在Person里面的域是由Per ...

  7. HTTP之缓存首部

    缓存分好多种:服务器缓存,第三方缓存,浏览器缓存等.其中浏览器缓存是代价最小的,因为浏览器缓存依赖的是客户端,而几乎不耗费服务器端的资源.浏览器做缓存需要给浏览器发送指定的Http头,告诉浏览器缓存多 ...

  8. Jmeter测试接口简单使用教程

    1.         打开 解决  apache-jmeter-2.13  然后进解压后的然后点击bin 文件里面的jmeter.bat  打开jmeter 2.         添加测试组件 1:添 ...

  9. java数据结构读书笔记--引论

    1 递归简论 需求:求出f(x)=2f(x-1)+x²的值.满足f(0)=0 public class Recursion { // 需求: 求出f(x)=2f(x-1)+x²的值.满足f(0)=0 ...

  10. @Deprecated使用技巧

    本文转自 http://www.cnblogs.com/hzhuxin/p/4645070.html 我们在做项目时,前期写的类中的一些代码可能由于需求变化的原因需要重写,有时重写时方法的传参和返回值 ...