Promi_38

abc 221B

Oct 2nd, 2021
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.57 KB | None | 0 0
  1. #include<iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     string s, t;
  8.     cin >> s >> t;
  9.  
  10.     int cnt = 0;
  11.     for(int i = 0; i < s.length(); i++)
  12.     {
  13.         if(i + 1 != s.length())
  14.         {
  15.             if(s[i] != t[i] && s[i+1] != t[i+1])
  16.             {
  17.                 if(s[i] == t[i+1] && s[i+1] == t[i]) cnt++;
  18.                 else
  19.                 {
  20.                     printf("No\n");
  21.                     return 0;
  22.                 }
  23.             }
  24.         }
  25.     }
  26.     bool somannai = false;
  27.     for(int i = 0; i < s.length(); i++)
  28.     {
  29.         if(s[i] != t[i])
  30.         {
  31.             somannai = true;
  32.             break;
  33.         }
  34.     }  
  35.     if(!somannai) printf("Yes\n");
  36.     else if(cnt == 1) printf("Yes\n");
  37.     else printf("No\n");
  38. }
  39.  
Advertisement
Add Comment
Please, Sign In to add comment