Cod sursa(job #532594)
Utilizator | Bagu Alexandru impulse | Data | 11 februarie 2011 23:53:37 |
---|---|---|---|
Problema | Xor Max | Scor | 15 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.64 kb |
#include<fstream>
using namespace std;
int v[100000];
int n;
int main()
{
ifstream in("xormax.in");
in>>n;
for(int i = 0; i < n; i++)
in>>v[i];
in.close();
int now = 0;
int start = 0, end = 0;
int max = 0;
for(int c = 0; c < n - 1; c++)
{
now = v[c];
for(int i = c + 1; i < n; i++)
{
now ^= v[i];
if(now > max)
{
max = now;
start = c;
end = i;
}
}
}
ofstream out("xormax.out");
out<<max<<" "<<start + 1 <<" "<<end + 1;
out.close();
}