Cod sursa(job #635306)

Utilizator i_am_testerCont Teste i_am_tester Data 19 noiembrie 2011 10:04:22
Problema PalM Scor 20
Compilator cpp Status done
Runda .com 2011 Marime 0.8 kb
#include <fstream>
#include <cstring>

using namespace std;

ifstream in("palm.in");
ofstream out("palm.out");

const int N=501;

char s[N],c[N];

int l;

bool verifica(int poz,int lung){
	char pozmax,maxim;
	int i;
	for(i=poz;i<=poz+lung-1;i++){
		if(s[2*poz+lung-1 - i]!=s[i]){
			return false;
		}
	}
	//return true;
	i=poz;
	while(s[i+1]>=s[i])
		i++;
	while(s[i+1]<=s[i])
		i++;
	if(i!=(poz+lung-1))
		return false;
	return true;
	/*for(i=poz;i<=poz+lung-1;i++){
		if(s[i]!=s[2*poz+lung-1 - i])
			return false;
		if(i<=pozmax && s[i]>maxim*/
}

int main(){
	in>>s;
	int i,j,k;
	l=strlen(s);
	for(i=l;i>=1;i--){
		for(j=0;j<=l-i;j++){
			if(verifica(j,i)){
				out<<i;
				/*for(k=j;k<=j+i-1;k++){
					out<<s[k];
				}*/
				return 0;
			}
		}
	}
	return 0;
}