Submission #961182

#TimeUsernameProblemLanguageResultExecution timeMemory
961182LucaIliePalindromic Partitions (CEOI17_palindromic)C++17
60 / 100
10021 ms6336 KiB
#include <bits/stdc++.h>

using namespace std;

int main() {
    int t;

    cin >> t;
    while ( t-- ) {
        string s;

        cin >> s;
        int l = 0, r = s.size() - 1, cuv = 0;
        while ( l <= r ) {
            string a = "", b = "";
            int i = 1;
            while ( i <= (r - l + 1) / 2 ) {
                a += s[l + i - 1];
                b += s[r - i + 1];
                reverse( b.begin(), b.end());
                if ( a == b )
                    break;
                reverse( b.begin(), b.end());
                i++;
            }
            if ( i <= (r - l + 1) / 2 ) {
                l += i;
                r -= i;
                cuv += 2;
            } else {
                cuv++;
                break;
            }
        }

        cout << cuv << "\n";
    }

    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...