#include "Annalib.h"
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i ++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i ++)
#define MP make_pair
using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
bool broken[150];
void Anna(int N, long long X, int K, int P[])
{
rep(i, 150) broken[i] = false;
rep(i, K) broken[P[i]] = true;
LL pw = 1;
while(pw + pw <= X) pw *= 3;
vector<int> bits;
while(X > 0) {
int cc = 0;
while(X >= pw) cc ++, X -= pw;
bits.push_back(cc);
pw /= 3;
}
while(pw > 0) {
bits.push_back(0);
pw /= 3;
}
reverse(bits.begin(), bits.end());
while(bits.back() == 0) bits.pop_back();
int ptr = 0;
for(int i = 0; i < N - 2; i += 3) {
int sum = 0;
if(!broken[i + 0]) sum ++;
if(!broken[i + 1]) sum ++;
if(!broken[i + 2]) sum ++;
if(ptr >= (int) bits.size() || sum == 0) {
Set(i + 0, 0);
Set(i + 1, 0);
Set(i + 2, 0);
continue;
}
if(bits[ptr] == 0) {
if(!broken[i + 0]) {
Set(i + 0, 1);
Set(i + 1, 0);
Set(i + 2, 0);
ptr ++;
continue;
}
if(!broken[i + 1] && !broken[i + 2]) {
Set(i + 0, 0);
Set(i + 1, 1);
Set(i + 2, 1);
ptr ++;
continue;
}
Set(i + 0, 0);
Set(i + 1, 0);
Set(i + 2, 0);
continue;
}
if(bits[ptr] == 1) {
if(!broken[i + 1]) {
Set(i + 0, 0);
Set(i + 1, 1);
Set(i + 2, 0);
ptr ++;
continue;
}
if(!broken[i + 0] && !broken[i + 2]) {
Set(i + 0, 1);
Set(i + 1, 0);
Set(i + 2, 1);
ptr ++;
continue;
}
Set(i + 0, 0);
Set(i + 1, 0);
Set(i + 2, 0);
continue;
}
if(bits[ptr] == 2) {
if(!broken[i + 2]) {
Set(i + 0, 0);
Set(i + 1, 0);
Set(i + 2, 1);
ptr ++;
continue;
}
if(!broken[i + 0] && !broken[i + 1]) {
Set(i + 0, 1);
Set(i + 1, 1);
Set(i + 2, 0);
ptr ++;
continue;
}
Set(i + 0, 0);
Set(i + 1, 0);
Set(i + 2, 0);
continue;
}
ptr ++;
}
}
#include "Brunolib.h"
#include <bits/stdc++.h>
using namespace std;
long long Bruno(int N, int A[])
{
long long X = 0, pw = 1;
for(int i = 0; i < N - 2; i += 3) {
int sum = A[i] + A[i + 1] + A[i + 2];
for(int j = 0; j < 3; j++) {
if(sum == 1 && A[i + j] == 1) {
X += pw * j;
pw *= 3;
}
if(sum == 2 && A[i + j] == 0) {
X += pw * j;
pw *= 3;
}
}
}
return X;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
41 ms |
2540 KB |
Output is partially correct - L* = 26 |
2 |
Partially correct |
38 ms |
2616 KB |
Output is partially correct - L* = 27 |
3 |
Partially correct |
34 ms |
2680 KB |
Output is partially correct - L* = 27 |
4 |
Partially correct |
32 ms |
2544 KB |
Output is partially correct - L* = 25 |
5 |
Partially correct |
33 ms |
2500 KB |
Output is partially correct - L* = 26 |
6 |
Partially correct |
32 ms |
2652 KB |
Output is partially correct - L* = 28 |
7 |
Partially correct |
33 ms |
2492 KB |
Output is partially correct - L* = 26 |
8 |
Partially correct |
38 ms |
2584 KB |
Output is partially correct - L* = 27 |
9 |
Partially correct |
37 ms |
2464 KB |
Output is partially correct - L* = 25 |
10 |
Partially correct |
33 ms |
2496 KB |
Output is partially correct - L* = 27 |
11 |
Partially correct |
31 ms |
2508 KB |
Output is partially correct - L* = 27 |
12 |
Partially correct |
32 ms |
2564 KB |
Output is partially correct - L* = 26 |
13 |
Partially correct |
33 ms |
2500 KB |
Output is partially correct - L* = 26 |
14 |
Partially correct |
32 ms |
2492 KB |
Output is partially correct - L* = 28 |
15 |
Partially correct |
32 ms |
2476 KB |
Output is partially correct - L* = 25 |
16 |
Partially correct |
37 ms |
2540 KB |
Output is partially correct - L* = 27 |
17 |
Partially correct |
34 ms |
2480 KB |
Output is partially correct - L* = 25 |
18 |
Partially correct |
32 ms |
2488 KB |
Output is partially correct - L* = 25 |
19 |
Partially correct |
33 ms |
2472 KB |
Output is partially correct - L* = 25 |
20 |
Partially correct |
33 ms |
2536 KB |
Output is partially correct - L* = 25 |
21 |
Partially correct |
34 ms |
2428 KB |
Output is partially correct - L* = 27 |
22 |
Partially correct |
38 ms |
2460 KB |
Output is partially correct - L* = 25 |
23 |
Partially correct |
34 ms |
2408 KB |
Output is partially correct - L* = 27 |
24 |
Partially correct |
32 ms |
2500 KB |
Output is partially correct - L* = 26 |
25 |
Partially correct |
33 ms |
2620 KB |
Output is partially correct - L* = 26 |
26 |
Partially correct |
33 ms |
2576 KB |
Output is partially correct - L* = 26 |
27 |
Partially correct |
34 ms |
2492 KB |
Output is partially correct - L* = 27 |
28 |
Partially correct |
38 ms |
2628 KB |
Output is partially correct - L* = 27 |
29 |
Partially correct |
34 ms |
2476 KB |
Output is partially correct - L* = 27 |
30 |
Partially correct |
33 ms |
2580 KB |
Output is partially correct - L* = 25 |
31 |
Partially correct |
33 ms |
2568 KB |
Output is partially correct - L* = 27 |
32 |
Partially correct |
36 ms |
2568 KB |
Output is partially correct - L* = 26 |
33 |
Partially correct |
33 ms |
2492 KB |
Output is partially correct - L* = 25 |
34 |
Partially correct |
33 ms |
2588 KB |
Output is partially correct - L* = 25 |
35 |
Partially correct |
40 ms |
2472 KB |
Output is partially correct - L* = 27 |
36 |
Partially correct |
40 ms |
2464 KB |
Output is partially correct - L* = 27 |
37 |
Partially correct |
33 ms |
2524 KB |
Output is partially correct - L* = 25 |
38 |
Partially correct |
37 ms |
2732 KB |
Output is partially correct - L* = 29 |
39 |
Partially correct |
33 ms |
2588 KB |
Output is partially correct - L* = 25 |
40 |
Partially correct |
32 ms |
2528 KB |
Output is partially correct - L* = 27 |