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 loop(i,n) for (ll i = 0; i < n; i++)
#define ll long long
#define INF 1e9+5
#define MAXN 300007
#define pb push_back
#define mp make_pair
typedef pair<ll,ll> pii;
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
ll t,n;
cin>>t;
while(t--){
string s,mleft, mright;
cin>>s;
n=(ll)s.size();
ll i=0,j=n-1,left=0,right=n-1,ans=1;
while(i<j){
mleft=s.substr(left,i-left+1);//de left a i
mright=s.substr(j,right-j+1);//de j a right
if(mleft==mright){
left=i+1; right=j-1;
ans+=2;
if(i==j-1)ans--;
}
i++; j--;
}
cout<<ans<<'\n';
}
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... |