Cod sursa(job #636932)

Utilizator bog29Antohi Bogdan bog29 Data 20 noiembrie 2011 02:41:34
Problema PalM Scor 0
Compilator cpp Status done
Runda .com 2011 Marime 0.51 kb
#include<fstream>
#define dmax 503
using namespace std;
ifstream in("palm.in");
ofstream out("palm.out");

char x[dmax];
int n, nxt[dmax], sirl[dmax];

int main()
{	
	in.getline(x, dmax, '\n');
	in.close();
	
	n = strlen(x);
	
	int i,j;
	int lng, mx=-1;
	
	for(i=1; i<n; i++)
	{	
		j=0;
		lng=0;
		while(x[i-j-1] == x[i+j+1] && x[i-j-1] < x[i-j] && i-j-1>=0 && i+j+1 <=n-1)
		{	lng++;
			j++;
		}	
		
		if(lng > mx)
			mx = lng;
	}	
	
	out<<2*mx+1;
	
	out.close();
	return 0;
	
}