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 solve(int st, int dr)
{
for(int len=1;st + len - 1 < dr - len + 1;len++)
{
bool ok = true;
for(int i=1;i<=len;i++)
{
if(s[st + i - 1] != s[dr - len + i])
{
ok = false;
break;
}
}
if(ok)
{
return 2 + solve(st + len, dr - len);
}
}
return 1;
}
void solve_test()
{
cin>>s;
s = "#" + s;
cout<<solve(1,s.size() - 1)<<'\n';
}
int main()
{
int t;
cin>>t;
for(int test=1;test<=t;test++)
{
solve_test();
}
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... |