#include <bits/stdc++.h>
using namespace std;
int mx = 1;
string s;
void rec(int l, int r, int kol){
if(l > r){
mx = max(mx, kol);
return;
}
if(r - l + 1 == 1){
mx = max(mx, kol + 1);
return;
}
int l2 = l, r2 = r;
string lf, rg;
while(l2 < r2){
lf += s[l2];
rg = s[r2] + rg;
if(lf != rg){
mx = max(kol + 1, mx);
}
else{
rec(l2 + 1, r2 - 1, kol + 2);
}
l2++;
r2--;
}
}
int t;
int main(){
cin >> t;
while(t--){
mx = 0;
cin >> s;
rec(0, (int)s.size() - 1, 0);
cout << mx << '\n';
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
256 KB |
Output is correct |
3 |
Correct |
2 ms |
256 KB |
Output is correct |
4 |
Correct |
2 ms |
256 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
256 KB |
Output is correct |
3 |
Correct |
2 ms |
256 KB |
Output is correct |
4 |
Correct |
2 ms |
256 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Execution timed out |
10047 ms |
384 KB |
Time limit exceeded |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
256 KB |
Output is correct |
3 |
Correct |
2 ms |
256 KB |
Output is correct |
4 |
Correct |
2 ms |
256 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Execution timed out |
10047 ms |
384 KB |
Time limit exceeded |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
256 KB |
Output is correct |
3 |
Correct |
2 ms |
256 KB |
Output is correct |
4 |
Correct |
2 ms |
256 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Execution timed out |
10047 ms |
384 KB |
Time limit exceeded |
7 |
Halted |
0 ms |
0 KB |
- |