Advertisement
Josif_tepe

Untitled

Dec 14th, 2023
936
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.78 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <string>
  4. #include <map>
  5. #include <set>
  6. #include <algorithm>
  7. using namespace std;
  8.  
  9. int main() {
  10.     ios_base::sync_with_stdio(false);
  11.     string s;
  12.     cin >> s;
  13.     int n = (int) s.size();
  14.     if(n <= 1000) {
  15.         int res = 0;
  16.         for(int i = 0; i < n; i++) {
  17.             string tmp = "";
  18.             for(int j = i; j < n; j++) {
  19.                 tmp += s[j];
  20.                 string rev_tmp = tmp;
  21.                 reverse(rev_tmp.begin(), rev_tmp.end());
  22.                 string x = tmp + rev_tmp + tmp + rev_tmp;
  23.                 if(s.find(x) != string::npos) {
  24.                     res = max(res, (int) x.size());
  25.                 }
  26.             }
  27.         }
  28.         cout << res << endl;
  29.     }
  30.    
  31.     return 0;
  32. }
  33.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement