Pagini recente » Cod sursa (job #1756959) | Cod sursa (job #562873) | Cod sursa (job #1359072) | Cod sursa (job #2696620) | Cod sursa (job #3153601)
#include <bits/stdc++.h>
#define FOR(n) for(int i = 1; i <= n; ++ i)
using namespace std;
/// INPUT / OUTPUT
ifstream fin("xormax.in");
ofstream fout("xormax.out");
/// GLOBAL VARIABLES
const int NMAX = 1e5 + 5;
int n, ans, st, dr;
int arr[NMAX];
/// SOLUTIA BRUTA
int main()
{
ios::sync_with_stdio(false);
fin.tie(NULL);
fout.tie(NULL);
fin >> n;
FOR(n)
fin >> arr[i];
for(int i = 1; i < n; ++ i)
{
int xor_max = arr[i];
if(xor_max > ans)
{
ans = xor_max;
st = i, dr = i;
}
for(int j = i + 1; j <= n; ++ j)
{
xor_max^=arr[j];
if(xor_max > ans)
{
ans = xor_max;
st = i, dr = j;
}
}
}
fout << ans << ' ' << st << ' ' << dr << '\n';
}