Cod sursa(job #1500389)

Utilizator ArkinyStoica Alex Arkiny Data 11 octombrie 2015 20:51:43
Problema Xor Max Scor 40
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.71 kb
#include<fstream>
#include<iostream>
#include<queue>
#include<algorithm>
using namespace std;

ifstream in("xormax.in");
ofstream out("xormax.out");
unsigned int N;

unsigned int V[100001];

int main()
{
	in >> N;
	unsigned int i, j, st, f, max = 0,s=0;
	for (i = 1;i <= N;++i)
		in >> V[i];
	max = V[1];
	st = 1;
	f = 1;
	for (i = 1;i < N;++i)
	{
		s = V[i];
		if (s > max)
		{
			max = V[i];
			st = i;
			f = i;
		}
		for (j = i + 1;j <= N;++j)
		{
			s = s^V[j];
			if (s == max)
			{
				if (j<=f)
				{
					max = s;
					st = i;
					f = j;
				}
			}
			else if (s > max)
			{
				max = s;
				st = i;
				f = j;
			}
		}
	}
		out << max <<" "<< st<<" " << f;
	return 0;
}