Cod sursa(job #1313546)

Utilizator thesvcoolmanLucian Bicsi thesvcoolman Data 10 ianuarie 2015 20:00:07
Problema Xor Max Scor 10
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.56 kb
#include<fstream>
#include<vector>

using namespace std;

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

vector<int> SUM;
int n, elem, xormax, b, e;

int main() {
    fin>>n;
    SUM.push_back(0);
    for(int i=1; i<=n; i++) {
        fin>>elem;
        SUM.push_back(SUM[i-1] xor elem);
    }

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

    return 0;
}