# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
99316 | TadijaSebez | Broken Device (JOI17_broken_device) | C++11 | 70 ms | 3312 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 "Annalib.h"
#define ll long long
const int N=1050;
int ans[N],p[N];
void Anna(int n, ll x, int k, int q[])
{
for(int i=0;i<n;i++) ans[i]=p[i]=0;
for(int i=0;i<k;i++) p[q[i]]=1;
for(int i=0;i+2<n;i+=3)
{
if(p[i]+p[i+1]+p[i+2]>=2) continue;
if(p[i])
{
if(x%2==0) ans[i+1]=ans[i+2]=1;
if(x%2==1) ans[i+2]=1;
x/=2;
}
else if(p[i+1])
{
if(x%2==0) ans[i]=1;
if(x%2==1) ans[i+2]=1;
x/=2;
}
else if(p[i+2])
{
if(x%2==0) ans[i]=1;
if(x%4==1) ans[i+1]=1;
if(x%4==3) ans[i]=ans[i+1]=1;
if(x%2==0) x/=2;
else x/=4;
}
else
{
if(x%4==0) ans[i]=ans[i+1]=ans[i+2]=1;
if(x%4==1) ans[i+1]=1;
if(x%4==2) ans[i]=ans[i+2]=1;
if(x%4==3) ans[i]=ans[i+1]=1;
x/=4;
}
}
for(int i=0;i<n;i++) Set(i,ans[i]);
}
#include "Brunolib.h"
#define ll long long
ll Bruno(int n, int ans[])
{
ll x=0;
for(int i=0;i+2<n;i+=3)
{
int tmp=4*ans[i]+2*ans[i+1]+ans[i+2];
if(tmp==1) x*=2,x++;
if(tmp==2) x*=4,x++;
if(tmp==3) x*=2;
if(tmp==4) x*=2;
if(tmp==5) x*=4,x+=2;
if(tmp==6) x*=4,x+=3;
if(tmp==7) x*=4;
}
return x;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |