Pagini recente » Cod sursa (job #2546369) | Cod sursa (job #808342) | Cod sursa (job #2958750) | Cod sursa (job #3281159) | Cod sursa (job #1500383)
#include<fstream>
#include<iostream>
#include<queue>
#include<algorithm>
using namespace std;
ifstream in("xormax.in");
ofstream out("xormax.out");
int N;
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 - i <= st - f)
{
max = s;
st = i;
f = j;
}
}
else if (s > max)
{
max = s;
st = i;
f = j;
}
}
}
out << max <<" "<< st<<" " << f;
return 0;
}