#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, 2);
else if((X & 3) == 2) setBlock(i, 5);
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 == 2) ans += (1LL<<bit);
else if(val == 5) ans += (2LL<<bit);
else if(val == 3) ans += (3LL<<bit);
bit += 2;
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
32 ms |
2800 KB |
Output is correct - L* = 40 |
2 |
Correct |
32 ms |
2800 KB |
Output is correct - L* = 40 |
3 |
Correct |
33 ms |
3056 KB |
Output is correct - L* = 40 |
4 |
Correct |
34 ms |
2800 KB |
Output is correct - L* = 40 |
5 |
Correct |
33 ms |
3056 KB |
Output is correct - L* = 40 |
6 |
Correct |
34 ms |
2800 KB |
Output is correct - L* = 40 |
7 |
Correct |
34 ms |
2800 KB |
Output is correct - L* = 40 |
8 |
Correct |
34 ms |
2800 KB |
Output is correct - L* = 40 |
9 |
Correct |
33 ms |
3056 KB |
Output is correct - L* = 40 |
10 |
Correct |
33 ms |
3056 KB |
Output is correct - L* = 40 |
11 |
Correct |
33 ms |
3056 KB |
Output is correct - L* = 40 |
12 |
Correct |
32 ms |
3064 KB |
Output is correct - L* = 40 |
13 |
Correct |
33 ms |
3056 KB |
Output is correct - L* = 40 |
14 |
Correct |
33 ms |
3056 KB |
Output is correct - L* = 40 |
15 |
Correct |
34 ms |
2800 KB |
Output is correct - L* = 40 |
16 |
Correct |
34 ms |
2800 KB |
Output is correct - L* = 40 |
17 |
Correct |
34 ms |
3056 KB |
Output is correct - L* = 40 |
18 |
Correct |
34 ms |
2808 KB |
Output is correct - L* = 40 |
19 |
Correct |
33 ms |
3096 KB |
Output is correct - L* = 40 |
20 |
Correct |
35 ms |
2800 KB |
Output is correct - L* = 40 |
21 |
Correct |
34 ms |
2808 KB |
Output is correct - L* = 40 |
22 |
Correct |
34 ms |
3064 KB |
Output is correct - L* = 40 |
23 |
Correct |
34 ms |
2800 KB |
Output is correct - L* = 40 |
24 |
Correct |
35 ms |
3056 KB |
Output is correct - L* = 40 |
25 |
Correct |
34 ms |
3056 KB |
Output is correct - L* = 40 |
26 |
Correct |
34 ms |
2800 KB |
Output is correct - L* = 40 |
27 |
Correct |
34 ms |
3056 KB |
Output is correct - L* = 40 |
28 |
Correct |
33 ms |
3056 KB |
Output is correct - L* = 40 |
29 |
Correct |
34 ms |
2832 KB |
Output is correct - L* = 40 |
30 |
Correct |
33 ms |
2800 KB |
Output is correct - L* = 40 |
31 |
Correct |
34 ms |
3312 KB |
Output is correct - L* = 40 |
32 |
Correct |
33 ms |
3064 KB |
Output is correct - L* = 40 |
33 |
Correct |
33 ms |
3056 KB |
Output is correct - L* = 40 |
34 |
Correct |
33 ms |
2800 KB |
Output is correct - L* = 40 |
35 |
Correct |
34 ms |
3056 KB |
Output is correct - L* = 40 |
36 |
Correct |
32 ms |
2800 KB |
Output is correct - L* = 40 |
37 |
Correct |
34 ms |
2800 KB |
Output is correct - L* = 40 |
38 |
Correct |
34 ms |
3056 KB |
Output is correct - L* = 40 |
39 |
Correct |
34 ms |
2800 KB |
Output is correct - L* = 40 |
40 |
Correct |
34 ms |
3312 KB |
Output is correct - L* = 40 |