#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){
if(r<l)return 0;
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 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
256 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
256 KB |
Output is correct |
6 |
Correct |
2 ms |
384 KB |
Output is correct |
7 |
Correct |
2 ms |
384 KB |
Output is correct |
8 |
Correct |
2 ms |
384 KB |
Output is correct |
9 |
Correct |
2 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
256 KB |
Output is correct |
6 |
Correct |
2 ms |
384 KB |
Output is correct |
7 |
Correct |
2 ms |
384 KB |
Output is correct |
8 |
Correct |
2 ms |
384 KB |
Output is correct |
9 |
Correct |
2 ms |
384 KB |
Output is correct |
10 |
Correct |
17 ms |
608 KB |
Output is correct |
11 |
Correct |
6 ms |
512 KB |
Output is correct |
12 |
Correct |
3 ms |
636 KB |
Output is correct |
13 |
Correct |
2 ms |
512 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
256 KB |
Output is correct |
6 |
Correct |
2 ms |
384 KB |
Output is correct |
7 |
Correct |
2 ms |
384 KB |
Output is correct |
8 |
Correct |
2 ms |
384 KB |
Output is correct |
9 |
Correct |
2 ms |
384 KB |
Output is correct |
10 |
Correct |
17 ms |
608 KB |
Output is correct |
11 |
Correct |
6 ms |
512 KB |
Output is correct |
12 |
Correct |
3 ms |
636 KB |
Output is correct |
13 |
Correct |
2 ms |
512 KB |
Output is correct |
14 |
Execution timed out |
10010 ms |
13420 KB |
Time limit exceeded |
15 |
Halted |
0 ms |
0 KB |
- |