Submission #131838

# Submission time Handle Problem Language Result Execution time Memory
131838 2019-07-17T19:38:34 Z Vardanyan Palindromic Partitions (CEOI17_palindromic) C++14
0 / 100
740 ms 131076 KB
#include <bits/stdc++.h>
using namespace std;
string st;
int solve(int s,int e,int l, int r){
    if(s == l && e == r && l == r) return 1;

    string s1,s2;
    for(int i = s;i<=l;i++) s1+=st[i];
    for(int i = r;i<=e;i++) s2+=st[i];
    if(s1 == s2){

       return 2+solve(l+1,r-1,l+1,r-1);
    }
    else{
        if(r-l == 1) return 1;
        if(r-l == 2) return 1;
        return solve(s,e,l+1,r-1);
    }
}
int main(){
    ios_base::sync_with_stdio(false);
    int t;
    cin>>t;
    while(t--){
        cin>>st;
        cout<<solve(0,st.length()-1,0,st.length()-1)<<endl;
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Runtime error 740 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 740 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 740 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 740 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -