Cod sursa(job #1010360)

Utilizator alex_HarryBabalau Alexandru alex_Harry Data 14 octombrie 2013 19:21:58
Problema PScPld Scor 20
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.71 kb
#include<fstream>
#include<cstring>
#define NMax 20050
using namespace std;
char s[NMax];
long long N, Sol;
void Read()
{
    ifstream fin("pscpld.in");
    fin.getline(s+1, NMax);
    N=strlen(s+1);
}
void Solve()
{
    int Left,Right,Mid;
    for (Mid=1; Mid<=N; Mid++)
      {
        for (Left=Mid, Right=Mid+1;Left>=1 && Right<=N && s[Left]==s[Right]; Left--, Right++,Sol++);
        //Sol+=(Right-Left-1)/2;
        for (Left=Right=Mid;Left>=1 && Right<=N && s[Left]==s[Right]; Left--, Right++,Sol++);
        //Sol+=(Right-Left+1)/2;
      }
}
void Print()
{
    ofstream fout("pscpld.out");
    fout<<Sol<<endl;
}


int main()
{
    Read();
    Solve();
    Print();
    return 0;
}