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 s;
int t,n;
int getans(int l,int r)
{
if(l>r)
return 0;
for(int last=l;last<=r;last++)
{
int lg=last-l+1;
int poz=r-lg+1;
if(poz>last)
{
bool ok=1;
for(int i=l,j=poz;i<=last&&j<=r;i++,j++)
if(s[i]!=s[j])
{
ok=0;
break;
}
if(ok)
return 2+getans(last+1,poz-1);
}
}
return 1;
}
void solve()
{
cin>>s;
n=s.size();
s=" "+s;
cout<<getans(1,n)<<'\n';
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cin>>t;
while(t--)
solve();
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... |