Cod sursa(job #1703884)
| Utilizator | Data | 17 mai 2016 19:03:24 | |
|---|---|---|---|
| Problema | Xor Max | Scor | 25 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.98 kb |
#include <fstream>
using namespace std;
const int NMAX = 100001;
int N, a[NMAX], smax = 0, nr, i, j, p1, p2;
int main()
{
ifstream f("xormax.in");
ofstream g("xormax.out");
f >> N;
for(i = 1; i <= N; i++)
f >> a[i];
for(i = 1; i <= N; i++)
{
nr = 0;
for(j = i; j <= N; j++)
{
nr ^= a[j];
if(nr > smax)
{
smax = nr;
p1 = i;
p2 = j;
}
else
if(nr == smax)
if(j < p2)
{
p1 = i;
p2 = j;
}
}
}
g << smax << ' ' << p1 << ' ' << p2;
f.close();
g.close();
return 0;
}
