Pagini recente » Cod sursa (job #1056452) | Cod sursa (job #131923) | Cod sursa (job #151662) | oni_11_12_7 | Cod sursa (job #1313654)
#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=n-1; i>=0; i--) {
SUM = 0;
for(int j=i; j>=0; j--) {
SUM ^= V[j];
if(SUM > xormax || (SUM == xormax and (i<e || (i == e and j > b)))) {
xormax = SUM;
b = j;
e = i;
}
}
}
fout<<xormax<<" "<<b+1<<" "<<e+1;
return 0;
}