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)
{
if(st > dr)
{
return 0;
}
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()
{
ios::sync_with_stdio(false);
cin.tie(0);
#ifdef home
freopen("nr.in","r",stdin);
freopen("nr.out","w",stdout);
#endif // home
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... |