Cod sursa(job #776860)

Utilizator ionut_blesneagIonut Blesneag ionut_blesneag Data 10 august 2012 16:00:57
Problema PScPld Scor 30
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.65 kb
#include<cstdio>
#include<cstring>
using namespace std;

int l,nrp,i,begin,end;
char v[1000002];

int main()
{
freopen("pscpld.in","r",stdin);
freopen("pscpld.out","w",stdout);
gets(v);
l=strlen(v);
nrp=l;
for(i=0; i<l-1; i++)
 { if(v[i]==v[i+1])
    {nrp++;
     begin=i;
     end=i+1;
     while(begin>=1 && end<l-1 && v[begin-1]==v[end+1])
        {nrp++;
         begin--;
         end++;}
     }
   if(i>0 && v[i-1]==v[i+1])
     {nrp++;
     begin=i-1;
     end=i+1;  
     while(begin>=1 && end<l-1 && v[begin-1]==v[end+1])
      {nrp++;
      begin--;
      end++;}
      }
  }  
printf("%d",nrp);          
return 0;}