Cod sursa(job #309425)
Utilizator | Data | 30 aprilie 2009 11:45:52 | |
---|---|---|---|
Problema | Xor Max | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.35 kb |
#include<fstream.h>
long s,n,i,max,c,xx,yy,z;
int main()
{
ifstream f("xormax.in");
ofstream g("xormax.out");
f>>n;
f>>c;
s=c;
max=s;
z=1;
for (i=2;i<=n;i++)
{
f>>c;
if ((s^c)<s) {s=c;z=i;}
else s=(s^c);
if (max<s || s==max && yy-xx<i-z) {max=s;xx=z;yy=i;}
}
g<<max<<' '<<xx<<' '<<yy<<'\n';
g.close();
return 0;
}