Advertisement
Guest User

B

a guest
Nov 17th, 2019
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. #define _CRT_SECURE_NO_WARNINGS
  2. #include <iostream>
  3. #include <cmath>
  4. #include <string>
  5. #include <algorithm>
  6. #include <vector>
  7.  
  8. using namespace std;
  9.  
  10.  
  11. int main() {
  12. #ifdef _DEBUG
  13. freopen("input.txt", "r", stdin);
  14. freopen("output.txt", "w", stdout);
  15. #endif
  16. ios::sync_with_stdio(false);
  17. string s;
  18. cin >> s;
  19. int n = s.size();
  20. int k = 0;
  21. int o = 1;
  22. int max = 1;
  23. for (int i = 0; i < n; ++i) {
  24. k = 0;
  25. int z = i;
  26. for (int j = n - 1; j >= i; --j) {
  27. if (s[i] != s[j]) {
  28. o = 0;
  29. i -= k;
  30. k = 0;
  31. }
  32. else {
  33. o = j + k;
  34. ++i;
  35. ++k;
  36. }
  37. }
  38. i = z;
  39. if (o - i + 1 > max) {
  40. max = o - i + 1;
  41. }
  42. }
  43. cout << max;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement