#include "Annalib.h"
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <vector>
using namespace std;
void Anna(int N, long long X, int K, int P[] ){
vector<int> bits(N);
for (int i = 0; i < N; ++i) {
bits[i] = i >= 60 ? 0: ((X & (1LL << i)) != 0);
}
vector<int> bad(N, 0);
for (int i = 0; i < K; ++i) {
bad[P[i]] = 1;
}
int pos = 0;
for (int i = 0; i < N; i += 3) {
int cnt = bad[i] + bad[i + 1] + bad[i + 2];
if (cnt == 0) {
if (bits[pos] == 0 && bits[pos + 1] == 0) {
Set(i , 1);
Set(i + 1, 0);
Set(i + 2, 0);
} else if (bits[pos] == 0 && bits[pos + 1] == 1) {
Set(i , 1);
Set(i + 1, 0);
Set(i + 2, 1);
} else if (bits[pos + 1] == 0) {
Set(i , 0);
Set(i + 1, 1);
Set(i + 2, 1);
} else {
Set(i , 1);
Set(i + 1, 1);
Set(i + 2, 1);
}
pos += 2;
} else if (cnt == 1) {
if (bits[pos] == 0) {
if (!bad[i + 1]) {
Set(i , 0);
Set(i + 1, 1);
Set(i + 2, 0);
pos += 1;
} else if (bits[pos + 1] == 0) {
Set(i , 1);
Set(i + 1, 0);
Set(i + 2, 0);
pos += 2;
} else {
Set(i , 1);
Set(i + 1, 0);
Set(i + 2, 1);
pos += 2;
}
} else if (bad[i + 2]) {
Set(i , 1);
Set(i + 1, 1);
Set(i + 2, 0);
pos += 1;
} else {
Set(i , 0);
Set(i + 1, 0);
Set(i + 2, 1);
pos += 1;
}
} else {
Set(i, 0);
Set(i + 1, 0);
Set(i + 2, 0);
}
}
}
#include "Brunolib.h"
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <vector>
using namespace std;
const int64_t value[] = {0, 1, 0, 1, 0, 2, 1, 3};
const int add[] = {0, 1, 1, 2, 2, 2, 1, 2};
long long Bruno( int N, int A[] ){
vector<int> bits(N, 0);
int64_t ans = 0;
int shift = 0;
for (int i = 0; i < N; i += 3) {
int v = 4 * A[i] + 2 * A[i + 1] + A[i + 2];
ans |= value[v] << shift;
shift += add[v];
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
32 ms |
4636 KB |
Output is correct - L* = 40 |
2 |
Correct |
41 ms |
4636 KB |
Output is correct - L* = 40 |
3 |
Correct |
39 ms |
4636 KB |
Output is correct - L* = 40 |
4 |
Correct |
35 ms |
4636 KB |
Output is correct - L* = 40 |
5 |
Correct |
39 ms |
4636 KB |
Output is correct - L* = 40 |
6 |
Correct |
39 ms |
4636 KB |
Output is correct - L* = 40 |
7 |
Correct |
35 ms |
4636 KB |
Output is correct - L* = 40 |
8 |
Correct |
35 ms |
4636 KB |
Output is correct - L* = 40 |
9 |
Correct |
32 ms |
4636 KB |
Output is correct - L* = 40 |
10 |
Correct |
35 ms |
4636 KB |
Output is correct - L* = 40 |
11 |
Correct |
32 ms |
4636 KB |
Output is correct - L* = 40 |
12 |
Correct |
46 ms |
4636 KB |
Output is correct - L* = 40 |
13 |
Correct |
41 ms |
4636 KB |
Output is correct - L* = 40 |
14 |
Correct |
28 ms |
4636 KB |
Output is correct - L* = 40 |
15 |
Correct |
28 ms |
4636 KB |
Output is correct - L* = 40 |
16 |
Correct |
41 ms |
4636 KB |
Output is correct - L* = 40 |
17 |
Correct |
32 ms |
4636 KB |
Output is correct - L* = 40 |
18 |
Correct |
38 ms |
4636 KB |
Output is correct - L* = 40 |
19 |
Correct |
41 ms |
4636 KB |
Output is correct - L* = 40 |
20 |
Correct |
39 ms |
4636 KB |
Output is correct - L* = 40 |
21 |
Correct |
39 ms |
4636 KB |
Output is correct - L* = 40 |
22 |
Correct |
39 ms |
4636 KB |
Output is correct - L* = 40 |
23 |
Correct |
35 ms |
4636 KB |
Output is correct - L* = 40 |
24 |
Correct |
28 ms |
4636 KB |
Output is correct - L* = 40 |
25 |
Correct |
35 ms |
4636 KB |
Output is correct - L* = 40 |
26 |
Correct |
36 ms |
4636 KB |
Output is correct - L* = 40 |
27 |
Correct |
35 ms |
4636 KB |
Output is correct - L* = 40 |
28 |
Correct |
32 ms |
4636 KB |
Output is correct - L* = 40 |
29 |
Correct |
45 ms |
4636 KB |
Output is correct - L* = 40 |
30 |
Correct |
52 ms |
4636 KB |
Output is correct - L* = 40 |
31 |
Correct |
28 ms |
4636 KB |
Output is correct - L* = 40 |
32 |
Correct |
35 ms |
4636 KB |
Output is correct - L* = 40 |
33 |
Correct |
35 ms |
4636 KB |
Output is correct - L* = 40 |
34 |
Correct |
52 ms |
4636 KB |
Output is correct - L* = 40 |
35 |
Correct |
35 ms |
4636 KB |
Output is correct - L* = 40 |
36 |
Correct |
35 ms |
4636 KB |
Output is correct - L* = 40 |
37 |
Correct |
35 ms |
4636 KB |
Output is correct - L* = 40 |
38 |
Correct |
32 ms |
4636 KB |
Output is correct - L* = 40 |
39 |
Correct |
35 ms |
4636 KB |
Output is correct - L* = 40 |
40 |
Correct |
35 ms |
4636 KB |
Output is correct - L* = 40 |