#include "Annalib.h"
#include <cstdio>
#include <cstring>
typedef long long i64;
static bool ans[200];
inline void append(int x, bool a, bool b, bool c) {
ans[x] = a;
ans[x + 1] = b;
ans[x + 2] = c;
}
void Anna(int n, i64 x, int k, int p[]) {
static bool flag[200];
memset(flag, 0, sizeof flag);
for (int i = 0; i < k; ++i) flag[p[i]] = true;
memset(ans, 0, sizeof ans);
for (int i = 0; i < n; i += 3) {
int cnt = flag[i] + flag[i + 1] + flag[i + 2];
if (cnt > 1) continue;
if (flag[i]) {
if (x & 1) append(i, 0, 1, 0); else append(i, 0, 0, 1);
x >>= 1;
} else if (flag[i + 1]) {
if (x & 1) append(i, 1, 0, 1); else append(i, 0, 0, 1);
x >>= 1;
} else if (flag[i + 2]) {
if (x & 1) {
append(i, 0, 1, 0);
x >>= 1;
} else if (x & 2) {
append(i, 1, 0, 0);
x >>= 2;
} else {
append(i, 1, 1, 0);
x >>= 2;
}
} else {
switch (x & 3) {
case 0: append(i, 1, 1, 0); break;
case 1: append(i, 0, 1, 1); break;
case 2: append(i, 1, 0, 0); break;
case 3: append(i, 1, 1, 1); break;
}
x >>= 2;
}
}
for (int i = 0; i < n; ++i) Set(i, ans[i] && !flag[i]);
}
#include "Brunolib.h"
typedef long long i64;
i64 Bruno(int n, int a[]) {
i64 res = 0, base = 1;
for (int i = 0; i < n; i += 3) {
int cur = a[i] | (a[i + 1] << 1) | (a[i + 2] << 2);
switch (cur) {
case 4:
base <<= 1;
break;
case 2:
case 5:
res += base;
base <<= 1;
break;
case 3:
base <<= 2;
break;
case 6:
res += base;
base <<= 2;
break;
case 1:
res += 2 * base;
base <<= 2;
break;
case 7:
res += 3 * base;
base <<= 2;
break;
}
}
return res;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
32 ms |
2836 KB |
Output is correct - L* = 40 |
2 |
Correct |
39 ms |
2836 KB |
Output is correct - L* = 40 |
3 |
Correct |
45 ms |
2836 KB |
Output is correct - L* = 40 |
4 |
Correct |
38 ms |
2836 KB |
Output is correct - L* = 40 |
5 |
Correct |
41 ms |
2836 KB |
Output is correct - L* = 40 |
6 |
Correct |
39 ms |
2836 KB |
Output is correct - L* = 40 |
7 |
Correct |
46 ms |
2836 KB |
Output is correct - L* = 40 |
8 |
Correct |
46 ms |
2836 KB |
Output is correct - L* = 40 |
9 |
Correct |
35 ms |
2836 KB |
Output is correct - L* = 40 |
10 |
Correct |
38 ms |
2836 KB |
Output is correct - L* = 40 |
11 |
Correct |
35 ms |
2836 KB |
Output is correct - L* = 40 |
12 |
Correct |
45 ms |
2836 KB |
Output is correct - L* = 40 |
13 |
Correct |
35 ms |
2836 KB |
Output is correct - L* = 40 |
14 |
Correct |
41 ms |
2836 KB |
Output is correct - L* = 40 |
15 |
Correct |
38 ms |
2836 KB |
Output is correct - L* = 40 |
16 |
Correct |
35 ms |
2836 KB |
Output is correct - L* = 40 |
17 |
Correct |
39 ms |
2836 KB |
Output is correct - L* = 40 |
18 |
Correct |
39 ms |
2836 KB |
Output is correct - L* = 40 |
19 |
Correct |
38 ms |
2836 KB |
Output is correct - L* = 40 |
20 |
Correct |
35 ms |
2836 KB |
Output is correct - L* = 40 |
21 |
Correct |
39 ms |
2836 KB |
Output is correct - L* = 40 |
22 |
Correct |
55 ms |
2836 KB |
Output is correct - L* = 40 |
23 |
Correct |
49 ms |
2836 KB |
Output is correct - L* = 40 |
24 |
Correct |
46 ms |
2836 KB |
Output is correct - L* = 40 |
25 |
Correct |
35 ms |
2836 KB |
Output is correct - L* = 40 |
26 |
Correct |
36 ms |
2836 KB |
Output is correct - L* = 40 |
27 |
Correct |
38 ms |
2836 KB |
Output is correct - L* = 40 |
28 |
Correct |
26 ms |
2836 KB |
Output is correct - L* = 40 |
29 |
Correct |
39 ms |
2836 KB |
Output is correct - L* = 40 |
30 |
Correct |
39 ms |
2836 KB |
Output is correct - L* = 40 |
31 |
Correct |
32 ms |
2836 KB |
Output is correct - L* = 40 |
32 |
Correct |
32 ms |
2836 KB |
Output is correct - L* = 40 |
33 |
Correct |
41 ms |
2836 KB |
Output is correct - L* = 40 |
34 |
Correct |
39 ms |
2836 KB |
Output is correct - L* = 40 |
35 |
Correct |
39 ms |
2836 KB |
Output is correct - L* = 40 |
36 |
Correct |
45 ms |
2836 KB |
Output is correct - L* = 40 |
37 |
Correct |
41 ms |
2836 KB |
Output is correct - L* = 40 |
38 |
Correct |
41 ms |
2836 KB |
Output is correct - L* = 40 |
39 |
Correct |
39 ms |
2836 KB |
Output is correct - L* = 40 |
40 |
Correct |
48 ms |
2836 KB |
Output is correct - L* = 40 |