Pagini recente » Solutii preONI 2007, Runda 4 | Cod sursa (job #306987) | Cod sursa (job #2531395) | Cod sursa (job #766331) | Cod sursa (job #561543)
Cod sursa(job #561543)
#include <fstream>
#include <queue>
using namespace std;
fstream fin("xormax.in", ios::in);
fstream fout("xormax.out", ios::out);
struct Max {int start; int stop; int value;} maxim, temp;
int main()
{
int n; queue<Max> max, nr;
fin >> n >> temp.value; temp.start = 1; temp.stop = 1; maxim = temp;
max.push(temp); nr.push(temp);
while(!fin.eof())
{
fin >> temp.value; temp.stop++; temp.start++;
nr.push(temp);
if((temp.value ^ nr.front().value) > maxim.value)
{
maxim.value = temp.value ^ nr.front().value;
maxim.start = nr.front().start; maxim.stop = temp.stop;
}
nr.pop();
if((temp.value ^ max.front().value) > maxim.value)
{
maxim.value = temp.value ^ max.front().value;
maxim.start = max.front().start; maxim.stop = temp.stop;
max.push(maxim);
max.pop();
}
}
fout << maxim.value << " " << maxim.start << " " << maxim.stop;
return 0;
}