Cod sursa(job #1715849)

Utilizator andreistanStan Andrei andreistan Data 11 iunie 2016 15:51:00
Problema Xor Max Scor 15
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.74 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, sx, sxmax, start, stop ;
    f >> n;
    for(i = 1; i <= n; i++)
    {
        f >> sx;
        s[i] = s[i - 1] ^ sx; //v[0]==0
    }
    sxmax=s[1];
    start=1;
    stop=1;
    for(i = 0; i <= n; i++)
    {
        for(j=i+1; j<=n; j++)
        {
            sx=s[i]^s[j];
            if(sx==sxmax)
            {
                start=i+1;
            }
            else if(sx>sxmax)
            {
                start=i+1;
                stop=j;
                sxmax=sx;
            }
        }
    }
    g << sxmax<<' '<<start<<' '<<stop;
    return 0;
}