pastebin

Paste Search Dynamic
Recent pastes
idxArray
  1. #include <iomanip>
  2. #include <string>
  3. #include <iostream>
  4. #include <algorithm>
  5. #include <math.h>
  6. #include <cmath>
  7. #include <queue>
  8. #include <deque>
  9. using namespace std;
  10. typedef long long ll;
  11. int arr[100005];
  12. int main()
  13. {
  14.         std::ios_base::sync_with_stdio(0);
  15.         cin.tie(0);
  16.         cout.tie(0);
  17.         int n, idx = 0, idxArray = 0, cntr = 0;
  18.         string s1, s2;
  19.         cin >> n >> s1 >> s2;
  20.         if (s1 == s2)
  21.         {
  22.                 cout << 0;
  23.                 return 0;
  24.         }
  25.         for (int i = 0; i < s2.size(); i++)
  26.         {
  27.                 if (s2[i] == s1[idx])idx++;
  28.                 else if (s2[i] != s1[idx])
  29.                 {
  30.                         arr[idxArray] = i;
  31.                         idxArray++;
  32.                         idx++;
  33.                 }
  34.         }                                 // 0 1 2
  35.         for (int i = 0; i < idxArray; i++)// 1 2 5
  36.         {
  37.                 if (arr[i + 1] - arr[i] > 1 && i != idxArray - 1) // 5-2 > 1
  38.                 {
  39.                         cntr++;
  40.                 }
  41.         }
  42.         cntr++;
  43.         cout << cntr;
  44.         return 0;
  45. }
Parsed in 0.013 seconds