Cod sursa(job #1313646)

Utilizator thesvcoolmanLucian Bicsi thesvcoolman Data 10 ianuarie 2015 22:17:10
Problema Xor Max Scor 15
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.6 kb
#include<fstream>
#include<vector>

using namespace std;

ifstream fin("xormax.in");
ofstream fout("xormax.out");

vector<long long> V;
long long n, elem, xormax, b, e, SUM;

int main() {
    fin>>n;
    for(int i=1; i<=n; i++) {
        fin>>elem;
        V.push_back(elem);
    }


    for(int i=0; i<n; i++) {
        SUM = 0;
        for(int j=i; j<n; j++) {
            SUM ^= V[j];
            if(SUM > xormax) {
                xormax = SUM;
                b = i;
                e = j;
            }
        }
    }
    fout<<xormax<<" "<<b+1<<" "<<e+1;

    return 0;
}