#include "Annalib.h"
#include "bits/stdc++.h"
using namespace std;
void Anna( int N, long long X, int K, int P[] ){
std::vector<int>bad(N, 0);
for(int i=0; i<K; i++)bad[P[i]]=1;
auto setBlock=[&](int index, int a, int b, int c)->void{
Set(index, a);
Set(index+1, b);
Set(index+2, c);
};
long long tmp = X;
for(int i=0; i<N; i+=3){
int cnt = bad[i] + bad[i+1] + bad[i+2];
if(tmp == 0 || cnt >= 2){
setBlock(i, 0, 0, 0);
}else if(cnt == 0){
int bit = tmp % 4;
tmp /= 4;
if(bit == 0) setBlock(i, 1, 0, 0);
else if(bit == 1)setBlock(i, 0, 1, 1);
else if(bit == 2)setBlock(i, 1, 0, 1);
else setBlock(i, 1, 1, 1);
}else{
int bit = tmp % 2;
tmp /= 2;
if(bad[i]){
if(bit == 0) setBlock(i, 0, 1, 0);
else setBlock(i, 0, 0, 1);
}else if(bad[i+1]){
if(bit == 0){
int bit2 = tmp % 2;
tmp /= 2;
if(bit2 == 0)setBlock(i, 1, 0, 0);
else setBlock(i, 1, 0, 1);
}
else setBlock(i, 0, 0, 1);
}else{
if(bit == 0) setBlock(i, 0, 1, 0);
else setBlock(i, 1, 1, 0);
}
}
}
}
#include "Brunolib.h"
#include "bits/stdc++.h"
using namespace std;
long long Bruno( int N, int A[] ){
std::vector<int>bits;
for(int i=0; i<N; i+=3){
int val = 4 * A[i] + 2 * A[i+1] + A[i+2];
if(val == 0)continue;
if(val == 1) bits.emplace_back(1);
else if(val == 2) bits.emplace_back(0);
else if(val == 3) bits.emplace_back(1), bits.emplace_back(0);
else if(val == 4) bits.emplace_back(0), bits.emplace_back(0);
else if(val == 5) bits.emplace_back(0), bits.emplace_back(1);
else if(val == 6) bits.emplace_back(1);
else bits.emplace_back(1), bits.emplace_back(1);
}
long long answer = 0LL;
while(!bits.empty()){
answer *= 2LL;
answer += bits.back();
bits.pop_back();
}
return answer;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
24 ms |
2776 KB |
Output is correct - L* = 40 |
2 |
Correct |
25 ms |
3032 KB |
Output is correct - L* = 40 |
3 |
Correct |
24 ms |
2760 KB |
Output is correct - L* = 40 |
4 |
Correct |
23 ms |
2772 KB |
Output is correct - L* = 40 |
5 |
Correct |
26 ms |
2940 KB |
Output is correct - L* = 40 |
6 |
Correct |
27 ms |
2764 KB |
Output is correct - L* = 40 |
7 |
Correct |
33 ms |
2812 KB |
Output is correct - L* = 40 |
8 |
Correct |
32 ms |
2784 KB |
Output is correct - L* = 40 |
9 |
Correct |
20 ms |
2860 KB |
Output is correct - L* = 40 |
10 |
Correct |
33 ms |
2752 KB |
Output is correct - L* = 40 |
11 |
Correct |
33 ms |
2572 KB |
Output is correct - L* = 40 |
12 |
Correct |
25 ms |
2752 KB |
Output is correct - L* = 40 |
13 |
Correct |
24 ms |
2748 KB |
Output is correct - L* = 40 |
14 |
Correct |
30 ms |
2748 KB |
Output is correct - L* = 40 |
15 |
Correct |
32 ms |
2732 KB |
Output is correct - L* = 40 |
16 |
Correct |
20 ms |
2860 KB |
Output is correct - L* = 40 |
17 |
Correct |
26 ms |
2772 KB |
Output is correct - L* = 40 |
18 |
Correct |
25 ms |
2920 KB |
Output is correct - L* = 40 |
19 |
Correct |
36 ms |
2844 KB |
Output is correct - L* = 40 |
20 |
Correct |
27 ms |
2872 KB |
Output is correct - L* = 40 |
21 |
Correct |
27 ms |
2864 KB |
Output is correct - L* = 40 |
22 |
Correct |
27 ms |
2788 KB |
Output is correct - L* = 40 |
23 |
Correct |
35 ms |
2772 KB |
Output is correct - L* = 40 |
24 |
Correct |
31 ms |
2844 KB |
Output is correct - L* = 40 |
25 |
Correct |
27 ms |
2840 KB |
Output is correct - L* = 40 |
26 |
Correct |
32 ms |
2744 KB |
Output is correct - L* = 40 |
27 |
Correct |
23 ms |
2752 KB |
Output is correct - L* = 40 |
28 |
Correct |
28 ms |
2848 KB |
Output is correct - L* = 40 |
29 |
Correct |
38 ms |
2840 KB |
Output is correct - L* = 40 |
30 |
Correct |
31 ms |
2744 KB |
Output is correct - L* = 40 |
31 |
Correct |
22 ms |
2748 KB |
Output is correct - L* = 40 |
32 |
Correct |
20 ms |
2776 KB |
Output is correct - L* = 40 |
33 |
Correct |
22 ms |
2772 KB |
Output is correct - L* = 40 |
34 |
Correct |
20 ms |
2776 KB |
Output is correct - L* = 40 |
35 |
Correct |
26 ms |
3032 KB |
Output is correct - L* = 40 |
36 |
Correct |
24 ms |
2756 KB |
Output is correct - L* = 40 |
37 |
Correct |
32 ms |
2792 KB |
Output is correct - L* = 40 |
38 |
Correct |
24 ms |
2780 KB |
Output is correct - L* = 40 |
39 |
Correct |
36 ms |
2924 KB |
Output is correct - L* = 40 |
40 |
Correct |
24 ms |
2960 KB |
Output is correct - L* = 40 |