Pagini recente » Cod sursa (job #503908) | Cod sursa (job #3185691) | Cod sursa (job #3264759) | Cod sursa (job #2253903) | Cod sursa (job #2239012)
#include <fstream>
const std :: string programName = "xormax";
std :: ifstream f(programName + ".in");
std :: ofstream g(programName + ".out");
const int NMAX = 1E5;
int main() {
int N;
f >> N;
int v[NMAX + 5];
for (int i = 1; i <= N; ++i)
f >> v[i];
int S(0), max(0);
int Xcopy = -1, Xcopy2 = -1;
for (int i = 1; i <= N; ++i) {
S = 0;
for (int j = i; j <= N; ++j) {
S ^= v[j];
if (S > max or (S == max and j - i < Xcopy2 - Xcopy)) {
max = S;
Xcopy = i;
Xcopy2 = j;
}
}
}
g << max << ' ' << Xcopy << ' ' << Xcopy2;
return 0x0;
}