Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _CRT_SECURE_NO_WARNINGS
- #include <iostream>
- #include <cmath>
- #include <string>
- #include <algorithm>
- #include <vector>
- using namespace std;
- int main() {
- #ifdef _DEBUG
- freopen("input.txt", "r", stdin);
- freopen("output.txt", "w", stdout);
- #endif
- ios::sync_with_stdio(false);
- string s;
- cin >> s;
- int n = s.size();
- int k = 0;
- int o = 1;
- int max = 1;
- for (int i = 0; i < n; ++i) {
- k = 0;
- int z = i;
- for (int j = n - 1; j >= i; --j) {
- if (s[i] != s[j]) {
- o = 0;
- i -= k;
- k = 0;
- }
- else {
- o = j + k;
- ++i;
- ++k;
- }
- }
- i = z;
- if (o - i + 1 > max) {
- max = o - i + 1;
- }
- }
- cout << max;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement