Cod sursa(job #275486)

Utilizator ooctavTuchila Octavian ooctav Data 10 martie 2009 15:02:30
Problema Xor Max Scor 15
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.69 kb
// xor max.cpp : Defines the entry point for the console application.
//

#include <stdio.h>

char c[900001];
int e[100001];
void parsare()
{
	int i,nr=1,x=0;
	fgets(c,900000,stdin);
	for(i=0;c[i];i++)
		if(c[i]==' ')
		{
			e[nr++]=x;
			x=0;
		}
		else
			x=10*x+c[i]-'0';
	e[nr]=x;
}
int main()
{
	freopen("xormax.in","r",stdin);
	freopen("xormax.out","w",stdout);
	int n,maxim=0,start=1,stop=1,i,j,curent;

	scanf("%d\n",&n);
	parsare();
	for(i=1;i<=n;i++)
	{
		curent=e[i];
		for(j=i+1;j<=n;j++)
		{
			curent=curent^e[j];
			if(curent>maxim)
			{
			maxim=curent;
			start=i;
			stop=j;
			}
		}
	}
	printf("%d %d %d",maxim,start,stop);

	return 0;
}