이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define sz(x) ((int)x.size())
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll mod=(ll)1e17-3;
int t,n;
char s[1000010];
int main() {
cin>>t;
int i,j;
while(t--) {
cin>>s;
n=strlen(s);
j=n;
ll hl=0,hr=0,pw=1,cnt=0;
for(i=0;i<n/2;i++) {
hl=(26*hl+s[i]-'a')%mod;
hr=(hr+(s[n-i-1]-'a')*pw%mod)%mod;
if(hl==hr) {
cnt+=2;
j=i;
hl=hr=0; pw=1;
} else pw=26*pw%mod;
}
if(n%2||j!=n/2-1) cnt++;
cout<<cnt<<endl;
}
return 0;
}
# | 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... |