This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |