Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <string>
- #include <map>
- #include <set>
- #include <algorithm>
- using namespace std;
- int main() {
- ios_base::sync_with_stdio(false);
- string s;
- cin >> s;
- int res =0 ;
- int n = (int) s.size();
- for(int sz = n / 4; sz >= 0; sz--) {
- for(int i = 0; i < n; i++) {
- if(i + 4 * sz - 1 < n) {
- if(s[i] == s[i + 2 * sz - 1] and s[i] == s[i + 2 * sz] and s[i] == s[i + 4 * sz - 1]) {
- bool ok = true;
- int cnt = 1;
- for(int j = i + 1; j < i + sz; j++) {
- 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]) {
- ok = false;
- break;
- }
- cnt++;
- }
- if(ok) {
- cout << sz * 4 << endl;
- return 0;
- }
- }
- }
- }
- }
- cout << res * 4 << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement