Pagini recente » Cod sursa (job #3163607) | Cod sursa (job #2055878) | Cod sursa (job #2353300) | Profil BlackNesta | Cod sursa (job #792472)
Cod sursa(job #792472)
#include <cstdio>
#define MAXN 100000
int N, V[MAXN];
void actsol(int max, int start, int stop,
int& oldmax, int& oldstart, int& oldstop)
{
if(max > oldmax ||
(max == oldmax && stop < oldstop) ||
(max == oldmax && stop == oldstop && start > oldstart))
{
oldmax = max;
oldstart = start;
oldstop = stop;
}
}
void read()
{
scanf("%d", &N);
for(int i = 0; i < N; i++)
scanf("%d", V + i);
}
void brut()
{
int a = -1, b, c;
for(int i = 0; i < N; i++)
{
for(int j = i; j < N; j++)
{
int xor_val = 0;
for(int k = i; k <= j; k++)
{
xor_val ^= V[k];
}
actsol(xor_val, i, j, a, b, c);
}
}
printf("%d %d %d\n", a, b + 1, c + 1);
}
int main()
{
freopen("xormax.in", "r", stdin);
freopen("xormax.out", "w", stdout);
read();
brut();
return 0;
}