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学习历程—HDU5476 Explore Track of Point(平面几何)(2015上海网赛09题)

    Problem Description In Geometry, the problem of track is very interesting. Because in some cases, th ...

  2. centos 6.7 (UDEV,、etc/hosts)安装 RAC 11.2.0.4 报错处理

    环境说明: ​db 11.2.0.4        os: centos 6.7    UDEV管理ASM      没有配置DNS服务器,采用/etc/hosts​报错: ​1.    CVU(Cl ...

  3. 1 slow requests are blocked > 32 sec解决方法

    [root@node1 ~]# ceph -s cluster: id: b8b4aa68-d825-43e9-a60a-781c92fec20e health: HEALTH_WARN Reduce ...

  4. AD9 如何画4层pcb板

    新建的PCB文件默认的是2层板,教你怎么设置4层甚至更多层板. 在工具栏点击Design-->Layer Stack Manager.进入之后显示的是两层板,添加为4层板,一般是先点top la ...

  5. .net关于应用程序缓存的一些疑惑

    疑惑:获取缓存后强制转换为实体对象传递给前台,如果前台对这个实体对象中属性更改的话缓存中的数据也随之改变,为啥??? 首先是创建缓存的方法: /// <summary> /// 创建缓存项 ...

  6. python+selenium简单实现拖动元素实例

    from  selenium  import  webdriver#引入ActionChains类from  selenium.webdriver.common.action_chains  impo ...

  7. Levenberg-Marquardt优化算法以及基于LM的BP-ANN

    一.LM最优化算法     最优化是寻找使得目标函数有最大或最小值的的参数向量.根据求导数的方法,可分为2大类.(1)若f具有解析函数形式,知道x后求导数速度快.(2)使用数值差分来求导数.根据使用模 ...

  8. Matlab常用函数(1)

    1.max() C = max(A)     A为向量,返回最大值.若为矩阵,以类向量为基准,返回每列的最大值的行向量.若为多维矩阵.切片返回每一个2维矩阵的行向 量. C = max(A,B)   ...

  9. Zabbix_proxy的架设

    一.安装zabbix-proxy与导入数据库 1. 安装 zabbix-server $ sudo rpm -ivh http://repo.zabbix.com/zabbix/3.0/rhel/7/ ...

  10. Tomcat+Nginx实现动静分离

    Tomcat是我们经常用的服务器,轻便快捷,但是数据量大的时候,会影响访问.响应速度,这时Nginx就出现了. Nginx可做反向代理.负载均衡.动态与静态资源的分离的工作,这里我们就用它来做动静分离 ...