#include <bits/stdc++.h>
using namespace std;
#define int int64_t
bool check(int s1, int s2, int l, string s){
for(int i=0;i<l;i++){
if(s[s1]!=s[s2])return false;
s1++;
s2++;
}
return true;
}
signed main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
int t;
cin>>t;
for(int T=0;T<t;T++){
string s;
cin>>s;
int n=s.size();
int pal=1;
int is=0;
int jcurr=n-1;
int jend=n;
while(jcurr>=(n+1)/2){
if(s[is]==s[jcurr]){
if(check(is,jcurr,jend-jcurr, s)){
pal+=2;
is+=(jend-jcurr);
jend=jcurr;
}
}
jcurr--;
}
cout<<pal<<"\n";
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
316 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
316 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
316 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
316 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |