SHARE
TWEET

Untitled

lalalalalalalaalalla Oct 22nd, 2019 75 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <vector>
  3. #include <string>
  4. #include <iomanip>
  5. #include <queue>
  6. #include <cmath>
  7. #include <algorithm>
  8. #include <tuple>
  9. #include <iomanip>
  10. #include <stdio.h>
  11. #include <numeric>
  12. #include <map>
  13. #include <bitset>
  14. #include <set>
  15. #include <stack>
  16. #include <queue>
  17. #include <unordered_set>
  18.  
  19.  
  20. #define int long long
  21. #define ll long long
  22. #define ull unsigned long long
  23. #define all(a) a.begin(), a.end()
  24. #define pii pair<int, int>
  25. #define pb push_back
  26. #define ld long double
  27.  
  28.  
  29. using namespace std;
  30.  
  31. const int INF = 1e17;
  32. //const int mod = 2600000069;
  33. //const int p = 179;
  34.  
  35. struct q {
  36.     int x, type, id;
  37.     q() {
  38.         x = 0;
  39.         type = -1;
  40.         id = -1;
  41.     }
  42.     q(int x_, int type_, int id_) {
  43.         x = x_;
  44.         type = type_;
  45.         id = id_;
  46.     }
  47. };
  48.  
  49. bool comp(q a, q b) {
  50.     return (a.x < b.x || a.type < b.type);
  51. }
  52.  
  53. signed main() {
  54.     ios_base::sync_with_stdio(0);
  55.     cin.tie(0);
  56.     cout.tie(0);
  57.     string s;
  58.     cin >> s;
  59.     int n = s.size();
  60.     int ind1 = 0, ind2 = n - 1, loss = 0, ans = -1;
  61.     while(ind1 < ind2) {
  62.         if (s[ind1] == s[ind2]) {
  63.             ind1++;
  64.             ind2--;
  65.         } else {
  66.             if (s[ind1 + 1] == s[ind2]) {
  67.                 ans = ind1 + 1;
  68.                 ind1+=2;
  69.                 ind2--;
  70.             } else if (s[ind2 - 1] == s[ind1]) {
  71.                 ans = ind2 + 1;
  72.                 ind2 -= 2;
  73.                 ind1++;
  74.             } else {
  75.                 cout << "0";
  76.                 return 0;
  77.             }
  78.             loss++;
  79.         }
  80.     }
  81.     if (loss > 1) {
  82.         cout << 0;
  83.         return 0;
  84.     }
  85.     cout << ans;
  86. }
  87. /*
  88.  
  89. */
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top