This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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(check(is,jcurr,jend-jcurr, s)){
if(jcurr==n/2)pal--;
pal+=2;
is+=(jend-jcurr);
jend=jcurr;
}
jcurr--;
}
cout<<pal<<"\n";
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |