Advertisement
Ankit_132

B

Oct 1st, 2023
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.29 KB | None | 0 0
  1.  
  2. #include <bits/stdc++.h>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.     int n, m;
  9.     string s, t;
  10.     cin>>n>>m>>s>>t;
  11.  
  12.     int x = (t.substr(0, n)==s);
  13.     int y = 2*(t.substr(m-n, n)==s);
  14.  
  15.     if(x+y == 3)        x=0, y=0;
  16.     else if(x+y == 0)        x=3, y=0;
  17.  
  18.     cout<<x+y<<"\n";
  19. }
  20.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement