#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 |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |