Codeforces Comparing Strings
/*
Lionel Messi is such a player that you may catch him, you may touch him, you may feel him
and definitely you may Love him.
Lionel Messi is Messi. A little Magician in this World.
*/
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false)
#define bfast cin.tie(0)
#define outs(x) cout << x << " "
#define outn(x) cout << x << "\n"
#define sf scanf
#define pf printf
#define nl puts("")
#define psb push_back
typedef long long LL;
typedef vector<int>vii;
typedef vector<LL>vll;
typedef map<int , int>mpci;
const int mod = 1000007;
const int high = 100;
int main()
{
fast;
int i;
mpci fr , se;
string first, second;
while(cin >> first >> second)
{
if(first.length() == second.length())
{
int in=0;
fr.clear();
for(i=0; i<second.length(); i++)
{
if(first[i] != second[i])
{
fr[in] = i;
in++;
}
if(in == 3)
{
break;
}
}
if(in==2 and first[fr[0]] == second[fr[1]] and first[fr[1]] == second[fr[0]])
{
outn("YES");
}
else
{
outn("NO");
}
}
else
{
outn("NO");
}
}
return 0;
}
Lionel Messi is such a player that you may catch him, you may touch him, you may feel him
and definitely you may Love him.
Lionel Messi is Messi. A little Magician in this World.
*/
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false)
#define bfast cin.tie(0)
#define outs(x) cout << x << " "
#define outn(x) cout << x << "\n"
#define sf scanf
#define pf printf
#define nl puts("")
#define psb push_back
typedef long long LL;
typedef vector<int>vii;
typedef vector<LL>vll;
typedef map<int , int>mpci;
const int mod = 1000007;
const int high = 100;
int main()
{
fast;
int i;
mpci fr , se;
string first, second;
while(cin >> first >> second)
{
if(first.length() == second.length())
{
int in=0;
fr.clear();
for(i=0; i<second.length(); i++)
{
if(first[i] != second[i])
{
fr[in] = i;
in++;
}
if(in == 3)
{
break;
}
}
if(in==2 and first[fr[0]] == second[fr[1]] and first[fr[1]] == second[fr[0]])
{
outn("YES");
}
else
{
outn("NO");
}
}
else
{
outn("NO");
}
}
return 0;
}
Comments
Post a Comment