#include <bits/stdc++.h>
using namespace std;
#define sync ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define ll logng long
const int m=1e9+7;
int get_hash(const string &s){
int pw=1,hs=0;
for(char c:s){
hs=(hs+(1ll*(c-'a'+1)*pw))%m;
pw=(pw*47)%m;
}
return hs;
}
int main(){
sync;
string s;
int t;
cin>>t;
while(t--){
cin>>s;
int cnt=1,n=s.size(),l=0,r=n-1,d=n/2;
while(r>=d && l<r){
if(s[r]==s[l] && get_hash(s.substr(l,n-r))==get_hash(s.substr(r,n-r))){
cnt+=2;
l+=n-r;
n=r;
}
r--;
}
cout<<cnt<<"\n";
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |