Advertisement
Josif_tepe

Untitled

Dec 14th, 2023
863
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.16 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 res =0 ;
  14.     int n = (int) s.size();
  15.     for(int sz = n / 4; sz >= 0; sz--) {
  16.         for(int i = 0; i < n; i++) {
  17.             if(i + 4 * sz - 1 < n) {
  18.                
  19.                 if(s[i] == s[i + 2 * sz - 1] and s[i] == s[i + 2 * sz] and s[i] == s[i + 4 * sz - 1]) {
  20.                     bool ok = true;
  21.                     int cnt = 1;
  22.                     for(int j = i + 1; j < i + sz; j++) {
  23.                        
  24.                         if(s[j] != s[i + 2 * sz - 1 - cnt] or s[j] != s[j + 2 * sz] or s[j] != s[i + 4 * sz - 1 - cnt]) {
  25.                             ok = false;
  26.                             break;
  27.                         }
  28.                         cnt++;
  29.                     }
  30.                     if(ok) {
  31.                         cout << sz * 4 << endl;
  32.                         return 0;
  33.                     }
  34.                 }
  35.             }
  36.         }
  37.     }
  38.     cout << res * 4 << endl;
  39.     return 0;
  40. }
  41.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement