Cod sursa(job #513821)

Utilizator perticas_catalinperticas catalin perticas_catalin Data 17 decembrie 2010 01:52:26
Problema Xor Max Scor 30
Compilator cpp Status done
Runda night_time_contest1 Marime 0.63 kb
#include <iostream>
#include <string>

using namespace std;

#define NM 100005

int N, A[NM];

int main()
{
	int best = -1, bestst, bestdr;
	
	freopen ("xormax.in", "r", stdin);
	freopen ("xormax.out", "w", stdout);
	
	scanf ("%d", &N);
	
	for (int i = 1; i <= N; ++i) scanf ("%d", &A[i]);
	
	for (int dr = 1; dr <= N; ++dr)
		for (int st = dr; st >= 1; --st)
		{
			int sum_xor = 0;
			
			for (int i = st; i <= dr; ++i) sum_xor = sum_xor ^ A[i];
			
			if (sum_xor > best)
			{
				best = sum_xor;
				bestst = st;
				bestdr = dr;
			}	
		}	
		
	printf ("%d %d %d", best, bestst, bestdr);	
	
	return 0;
}