Cod sursa(job #2905763)
| Utilizator | Data | 23 mai 2022 17:46:30 | |
|---|---|---|---|
| Problema | Xor Max | Scor | 20 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva de probleme | Marime | 0.92 kb |
#include <fstream>
using namespace std;
ifstream fin("xormax.in");
ofstream fout("xormax.out");
int n;
int v[100009];
int main()
{
fin>>n;
for(int i=1;i<=n;i++)
{
fin>>v[i];
}
int Max=-1, start, stop;
for(int i=1;i<=n;i++)
{
int x;
for(int j=i;j<=n;j++)
{
if(j==i)
{
x=v[i];
continue;
}
int nou=(x^v[j]);
x=nou;
if(x>Max)
{
Max=x;
start=i;
stop=j;
}
if(x==Max && j<stop)
{
start=i;
stop=j;
}
if(x==Max && j==stop && start<i)
{
start=i;
stop=j;
}
}
}
fout<<Max<<' '<<start<<' '<<stop;
return 0;
}
