Cod sursa(job #1715854)
| Utilizator | Data | 11 iunie 2016 15:56:25 | |
|---|---|---|---|
| Problema | Xor Max | Scor | 40 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.62 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream f("xormax.in");
ofstream g("xormax.out");
int s[100001], n;
int main()
{
int i, j, x, sxmax, start, stop ;
f >> n;
for(i = 1; i <= n; i++)
{
f >> x;
s[i] = s[i - 1] ^ x; //s[0]==0
}
sxmax=s[1];
start=1;
stop=1;
for(i = 1; i <= n; i++)
{
for(int j = i-1; j >=0; j--)
if((s[i]^s[j]) > sxmax)
{
sxmax = s[i]^s[j];
start = j+1;
stop = i;
}
}
g << sxmax<<' '<<start<<' '<<stop;
return 0;
}
