-
Notifications
You must be signed in to change notification settings - Fork 0
/
A.cpp
46 lines (46 loc) · 889 Bytes
/
A.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include<stdio.h>
#include<string.h>
int main()
{
int n,m,i,a,b,sum=0;
static char s[100001],t[100001];
scanf("%s%s",&s,&t);
n=strlen(s);
m=strlen(t);
if(n!=m)
printf("NO");
else
{
for(i=0;i<n;i++)
{
if(s[i]!=t[i])
sum++;
}
if(sum!=2)
printf("NO");
else
{
for(i=0;i<n;i++)
{
if(s[i]!=t[i])
{
a=i;
break;
}
}
for(i=a+1;i<n;i++)
{
if(s[i]!=t[i])
{
b=i;
break;
}
}
if(s[a]==t[b] && t[a]==s[b])
printf("YES");
else
printf("NO");
}
}
return 0;
}