# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1029867 | lucri | cmp (balkan11_cmp) | C++17 | 1313 ms | 82520 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "cmp.h"
void remember(int n)
{
int nr=0;
int b=0,e=4095,r=(e-b+1)/12+1;
for(;b<=e;b+=r)
{
++nr;
if(b<=n&&n<b+r)
{
bit_set(nr);
e=b+r-1;
break;
}
}
r=(e-b+1)/10+1;
nr=12;
for(;b<=e;b+=r)
{
++nr;
if(b<=n&&n<b+r)
{
bit_set(nr);
e=b+r-1;
break;
}
}
r=(e-b+1)/8+1;
nr=22;
for(;b<=e;b+=r)
{
++nr;
if(b<=n&&n<b+r)
{
bit_set(nr);
e=b+r-1;
break;
}
}
r=(e-b+1)/6+1;
nr=30;
for(;b<=e;b+=r)
{
++nr;
if(b<=n&&n<b+r)
{
bit_set(nr);
e=b+r-1;
break;
}
}
}
int compare(int b)
{
int nr=0;
int bi=0,ei=4095,r=(ei-bi+1)/12+1;
if(b<bi+6*r)
{
bool ok1=false,ok2=false;
nr=13;
for(bi=r*11;bi>=0;bi-=r)
{
--nr;
if(bi<=b&&b<bi+r)
{
if(bit_get(nr)==1)
ok1=true;
else
ok2=true;
}
else if(ok2==true)
{
if(bit_get(nr)==1)
ok1=true;
}
}
if(ok2==true)
{
if(ok1==true)
return 1;
else
return -1;
}
}
else
{
bool ok1=false,ok2=false;
nr=0;
for(bi=0;bi<=ei;bi+=r)
{
++nr;
if(bi<=b&&b<bi+r)
{
if(bit_get(nr)==1)
ok1=true;
else
ok2=true;
}
else if(ok2==true)
{
if(bit_get(nr)==1)
ok1=true;
}
}
if(ok2==true)
{
if(ok1==true)
return -1;
else
return 1;
}
}
while(b>=r)
b-=r;
bi=0,ei=r-1;
r=(ei-bi+1)/10+1;
if(b<bi+5*r)
{
bool ok1=false,ok2=false;
nr=23;
for(bi=r*9;bi>=0;bi-=r)
{
--nr;
if(bi<=b&&b<bi+r)
{
if(bit_get(nr)==1)
ok1=true;
else
ok2=true;
}
else if(ok2==true)
{
if(bit_get(nr)==1)
ok1=true;
}
}
if(ok2==true)
{
if(ok1==true)
return 1;
else
return -1;
}
}
else
{
bool ok1=false,ok2=false;
nr=12;
for(bi=0;bi<=ei;bi+=r)
{
++nr;
if(bi<=b&&b<bi+r)
{
if(bit_get(nr)==1)
ok1=true;
else
ok2=true;
}
else if(ok2==true)
{
if(bit_get(nr)==1)
ok1=true;
}
}
if(ok2==true)
{
if(ok1==true)
return -1;
else
return 1;
}
}
while(b>=r)
b-=r;
bi=0,ei=r-1;
r=(ei-bi+1)/8+1;
if(b<bi+4*r)
{
bool ok1=false,ok2=false;
nr=31;
for(bi=r*7;bi>=0;bi-=r)
{
--nr;
if(bi<=b&&b<bi+r)
{
if(bit_get(nr)==1)
ok1=true;
else
ok2=true;
}
else if(ok2==true)
{
if(bit_get(nr)==1)
ok1=true;
}
}
if(ok2==true)
{
if(ok1==true)
return 1;
else
return -1;
}
}
else
{
bool ok1=false,ok2=false;
nr=22;
for(bi=0;bi<=ei;bi+=r)
{
++nr;
if(bi<=b&&b<bi+r)
{
if(bit_get(nr)==1)
ok1=true;
else
ok2=true;
}
else if(ok2==true)
{
if(bit_get(nr)==1)
ok1=true;
}
}
if(ok2==true)
{
if(ok1==true)
return -1;
else
return 1;
}
}
while(b>=r)
b-=r;
bi=0,ei=r-1;
r=(ei-bi+1)/6+1;
if(b<bi+3*r)
{
bool ok1=false,ok2=false;
nr=37;
for(bi=r*5;bi>=0;bi-=r)
{
--nr;
if(bi<=b&&b<bi+r)
{
if(bit_get(nr)==1)
ok1=true;
else
ok2=true;
}
else if(ok2==true)
{
if(bit_get(nr)==1)
ok1=true;
}
}
if(ok2==true)
{
if(ok1==true)
return 1;
else
return -1;
}
}
else
{
bool ok1=false,ok2=false;
nr=30;
for(bi=0;bi<=ei;bi+=r)
{
++nr;
if(bi<=b&&b<bi+r)
{
if(bit_get(nr)==1)
ok1=true;
else
ok2=true;
}
else if(ok2==true)
{
if(bit_get(nr)==1)
ok1=true;
}
}
if(ok2==true)
{
if(ok1==true)
return -1;
else
return 1;
}
}
while(b>=r)
b-=r;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |