#include <bits/stdc++.h>
#define pb push_back
#define X first
#define Y second
#define pii pair<int, int>
using namespace std;
bool same(int l, int r, int len, vector<int>&wrd){
for(int i = 0; i<=len; i++){
if(wrd[l+i] != wrd[r+i-len])return false;
}
return true;
}
int dp(int l, int r, vector<int>&wrd){
for(int i = 0; i+l < r-i ;i++){
if(same(l, r, i, wrd))return dp(l+i+1, r-i-1, wrd)+2;
}
return 1;
}
void solve(){
string in; vector<int> wrd;
cin >> in;
for(auto i : in)wrd.pb(i-'a');
//for(int i : wrd)cout << i <<' ';
cout << dp(0, wrd.size()-1, wrd)<< '\n';
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
int t; cin >> t;
while(t--){
solve();
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |