Submission #131840

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
1318402019-07-17 19:40:21VardanyanPalindromic Partitions (CEOI17_palindromic)C++14
60 / 100
665 ms131076 KiB
#include <bits/stdc++.h>
using namespace std;
string st;
int solve(int s,int e,int l, int r){
if(l>r) return 0;
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;
}
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...