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 long long
#define ff first
#define ss second
#define pb push_back
vector<int>ans;
void fun(){
string s;
cin>>s;
int n=s.size();
int l=0,r=n-1;
string a,b;
int cnt=0;
while(r>l){
a+=s[l];
b=s[r]+b;
if(a==b){
a.clear();
b.clear();
cnt+=2;
}
r--;
l++;
}
if(n%2==0 and s[n/2]==s[n/2-1])cnt--;
ans.pb(cnt+1);
}
signed main(){
int t;
cin>>t;
while(t--)fun();
for(auto a:ans)cout<<a<<endl;
}
# | 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... |