# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
92443 | Alexa2001 | Broken Device (JOI17_broken_device) | C++17 | 63 ms | 3568 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"
bool broken[200];
void setBlock(int i, int val)
{
Set(i+2, val&1); val >>= 1;
Set(i+1, val&1); val >>= 1;
Set(i, val&1);
}
void Anna( int N, long long X, int K, int P[] )
{
int i;
for(i=0; i<N; ++i) broken[i] = 0;
for(i=0; i<K; ++i) broken[P[i]] = 1;
for(i=0; i<N; i+=3)
{
int x, y, z;
x = broken[i], y = broken[i+1], z = broken[i+2];
if(x+y+z >= 2) /// skip
{
setBlock(i, 0);
continue;
}
if(x+y+z == 0)
{
if((X & 3) == 0) setBlock(i, 7);
else if((X & 3) == 1) setBlock(i, 5);
else if((X & 3) == 2) setBlock(i, 2);
else setBlock(i, 3);
X >>= 2;
}
else
{
if(!(X&1) && !z) setBlock(i, 1);
else if((X&1) && !x) setBlock(i, 4);
else if(!(X&1) && z) setBlock(i, 6);
else
{
if(X&2) setBlock(i, 3);
else setBlock(i, 2);
X >>= 1;
}
X >>= 1;
}
}
}
#include "Brunolib.h"
long long Bruno( int N, int A[] )
{
int i, bit = 0;
long long ans = 0;
for(i=0; i<N; i+=3)
{
int val = (A[i]<<2) + (A[i+1]<<1) + A[i+2];
if(!val) continue;
if(val == 1 || val == 6)
{
++bit;
continue;
}
if(val == 4)
{
ans += (1LL<<bit);
++bit;
continue;
}
if(val == 5) ans += (1LL<<bit);
else if(val == 2) ans += (2LL<<bit);
else if(val == 3) ans += (3LL<<bit);
bit += 2;
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |