Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <string>
- #include <iomanip>
- #include <queue>
- #include <cmath>
- #include <algorithm>
- #include <tuple>
- #include <iomanip>
- #include <stdio.h>
- #include <numeric>
- #include <map>
- #include <bitset>
- #include <set>
- #include <stack>
- #include <queue>
- #include <unordered_set>
- #define int long long
- #define ll long long
- #define ull unsigned long long
- #define all(a) a.begin(), a.end()
- #define pii pair<int, int>
- #define pb push_back
- #define ld long double
- using namespace std;
- const int INF = 1e17;
- //const int mod = 2600000069;
- //const int p = 179;
- struct q {
- int x, type, id;
- q() {
- x = 0;
- type = -1;
- id = -1;
- }
- q(int x_, int type_, int id_) {
- x = x_;
- type = type_;
- id = id_;
- }
- };
- bool comp(q a, q b) {
- return (a.x < b.x || a.type < b.type);
- }
- signed main() {
- ios_base::sync_with_stdio(0);
- cin.tie(0);
- cout.tie(0);
- string s;
- cin >> s;
- int n = s.size();
- int ind1 = 0, ind2 = n - 1, loss = 0, ans = -1;
- while(ind1 < ind2) {
- if (s[ind1] == s[ind2]) {
- ind1++;
- ind2--;
- } else {
- if (s[ind1 + 1] == s[ind2]) {
- ans = ind1 + 1;
- ind1+=2;
- ind2--;
- } else if (s[ind2 - 1] == s[ind1]) {
- ans = ind2 + 1;
- ind2 -= 2;
- ind1++;
- } else {
- cout << "0";
- return 0;
- }
- loss++;
- }
- }
- if (loss > 1) {
- cout << 0;
- return 0;
- }
- cout << ans;
- }
- /*
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement