fork download
  1. #include <bits/stdc++.h>
  2. #define ll long long
  3. #define m 1000000007
  4. using namespace std;
  5.  
  6. int main() {
  7. // your code goes here
  8. std::ios::sync_with_stdio(false);
  9. int ans,i,n;
  10. string s;
  11. cin>>s;
  12. n=s.length();
  13. ans=n;
  14. for(i=0;i<n;i++)
  15. {
  16. int l=i-1,r=i+1,c=0;
  17. while(l>=0 && r<n && s[l]==s[r])
  18. {c+=1;
  19. l--;
  20. r++;}
  21. ans+=c;
  22. //cout<<ans<<endl;
  23. }
  24. for(i=0;i<n;i++)
  25. {
  26. int l=i-1,r=i,c=0;
  27. while(l>=0 && r<n && s[l]==s[r])
  28. {c+=1;
  29. l--;
  30. r++;}
  31. ans+=c;
  32. //cout<<ans<<endl;
  33. }
  34.  
  35.  
  36. cout<<ans;
  37.  
  38.  
  39. return 0;
  40. }
Success #stdin #stdout 0s 15224KB
stdin
fzxldqljeiiah
stdout
14