Two strings s and t of the same length are given. Determine whether it is possible to make t from s using exactly one reverse of some its substring.
Input
The first line contains the string s, and the second — the string t. Both strings have the same length from 1 to 200000 characters and consist of lowercase Latin letters.
Output
Output «YES», if it is possible to reverse some substring of s to make s equal to t, and «NO», otherwise.
Examples
Input
abcdefg abedcfg
Output
YES
Input
abcdefg abdecfg
Output
NO
//Full of love and hope for life
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <queue>
#define inf 0x3f3f3f3f
//https://paste.ubuntu.com/
using namespace std;
int main()
{
int g,h;
char s[200010],ss[200010],c;
scanf("%s",s);
scanf("%s",ss);
if(strcmp(s,ss)==0){
cout << "YES";
}
else{
int a=strlen(s);
for(int i=0;i<a;i++){
if(s[i]!=ss[i]){
g=i;
break;
}
}
for(int i=a-1;i>=g;i--){
if(s[i]!=ss[i]){
h=i;
break;
}
}
for(int i=g;i<=(h+g)/2;i++){
c=ss[i];
ss[i]=ss[h-i+g];
ss[h-i+g]=c;
}
if(strcmp(s,ss)==0){
cout << "YES";
}
else{
cout << "NO";
}
}
return 0;
}