| 比赛 |
NOIP2025模拟赛2 |
评测结果 |
AAAAAAAAAAAAAAAA |
| 题目名称 |
回文块 |
最终得分 |
100 |
| 用户昵称 |
李奇文 |
运行时间 |
0.147 s |
| 代码语言 |
C++ |
内存使用 |
4.21 MiB |
| 提交时间 |
2025-11-25 10:39:29 |
显示代码纯文本
#include<bits/stdc++.h>
#define ull unsigned long long
using namespace std;
int t;
ull bs=131;
int main(){
freopen("palin.in","r",stdin);
freopen("palin.out","w",stdout);
ios::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
cin>>t;
while(t--){
string s;cin>>s;
int n=s.length(),ans=0;
ull a=0,b=0,p=1;
for(int i(0);i<(n>>1);++i){
a=a*bs+s[i],b=b+s[n-i-1]*p,p*=bs;
if(a==b){
ans+=2;
a=b=0;
p=1;
}
}
cout<<ans+(n%2||a)<<"\n";
}
return 0;
}