#include "Annalib.h"
#include <bits/stdc++.h>
using namespace std;
namespace {
void __print() {
cerr << "]\n";
}
template<class T, class... V>
void __print(T t, V... v) {
cerr << t;
if (sizeof...(v)) {
cerr << ", ";
}
__print(v...);
}
#define debug(x...) cerr << "["<< #x << "] = ["; __print(x);
void set(int i, string s) {
for (auto j : {0, 1, 2}) {
Set(i + j, s[j] - '0');
}
}
void msg(int i, int type) {
if (type == 0) {
set(i, "000");
} else if (type == 1) {
set(i, "011");
} else if (type == 2) {
set(i, "101");
} else if (type == 3) {
set(i, "111");
} else if (type == 4) {
set(i, "110");
} else if (type == 5) {
set(i, "001");
} else if (type == 6) {
set(i, "010");
} else {
set(i, "100");
}
}
int conv(string s) {
if (s == "10") {
return 1;
}
if (s == "01") {
return 2;
}
if (s == "00") {
return 7;
}
return 3;
}
}
void Anna(int N, long long X, int K, int *P) {
vector<bool> broke(N);
for (int i = 0; i < K; ++i) {
broke[P[i]] = 1;
}
int ptr = 0;
for (int i = 0; i < N; i += 3) {
if (ptr == 60) {
msg(i, 0);
continue;
}
int cnt = 0;
for (auto j : {0, 1, 2}) {
cnt += broke[i + j];
}
if (cnt > 1) {
msg(i, 0);
} else if (cnt == 0) {
string m;
m += (X >> ptr++ & 1) + '0';
m += (X >> ptr++ & 1) + '0';
msg(i, conv(m));
} else {
int c = X >> ptr++ & 1;
if (c == 0) {
if (!broke[i + 1]) {
msg(i, 6);
} else {
int d = X >> ptr++ & 1;
msg(i, d ? 2 : 7);
}
} else {
msg(i, broke[i + 2] ? 4 : 5);
}
}
}
}
#include "Brunolib.h"
#include <bits/stdc++.h>
using namespace std;
namespace {
void __print() {
cerr << "]\n";
}
template<class T, class... V>
void __print(T t, V... v) {
cerr << t;
if (sizeof...(v)) {
cerr << ", ";
}
__print(v...);
}
#define debug(x...) cerr << "["<< #x << "] = ["; __print(x);
string decode(string m) {
if (m == "000") {
return "";
}
if (m == "011") {
return "10";
}
if (m == "101") {
return "01";
}
if (m == "111") {
return "11";
}
if (m == "100") {
return "00";
}
if (m == "110" || m == "001") {
return "1";
}
return "0";
}
}
long long Bruno(int N, int *A) {
string S;
for (int i = 0; i < N; i += 3) {
string m;
for (auto j : {0, 1, 2}) {
m += A[i + j] + '0';
}
S += decode(m);
}
long long res = 0;
for (int i = 0; i < 60; ++i) {
if (S[i] == '1') {
res += 1LL << i;
}
}
return res;
}
Compilation message
Anna.cpp:8:8: warning: 'void {anonymous}::__print()' defined but not used [-Wunused-function]
8 | void __print() {
| ^~~~~~~
Bruno.cpp:8:8: warning: 'void {anonymous}::__print()' defined but not used [-Wunused-function]
8 | void __print() {
| ^~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
24 ms |
2776 KB |
Output is correct - L* = 40 |
2 |
Correct |
28 ms |
2868 KB |
Output is correct - L* = 40 |
3 |
Correct |
24 ms |
2932 KB |
Output is correct - L* = 40 |
4 |
Correct |
25 ms |
2772 KB |
Output is correct - L* = 40 |
5 |
Correct |
25 ms |
2856 KB |
Output is correct - L* = 40 |
6 |
Correct |
25 ms |
2772 KB |
Output is correct - L* = 40 |
7 |
Correct |
25 ms |
2772 KB |
Output is correct - L* = 40 |
8 |
Correct |
34 ms |
2780 KB |
Output is correct - L* = 40 |
9 |
Correct |
26 ms |
2776 KB |
Output is correct - L* = 40 |
10 |
Correct |
24 ms |
2812 KB |
Output is correct - L* = 40 |
11 |
Correct |
24 ms |
2776 KB |
Output is correct - L* = 40 |
12 |
Correct |
24 ms |
2756 KB |
Output is correct - L* = 40 |
13 |
Correct |
24 ms |
2752 KB |
Output is correct - L* = 40 |
14 |
Correct |
24 ms |
2780 KB |
Output is correct - L* = 40 |
15 |
Correct |
25 ms |
2680 KB |
Output is correct - L* = 40 |
16 |
Correct |
26 ms |
2772 KB |
Output is correct - L* = 40 |
17 |
Correct |
25 ms |
2772 KB |
Output is correct - L* = 40 |
18 |
Correct |
24 ms |
2768 KB |
Output is correct - L* = 40 |
19 |
Correct |
32 ms |
2776 KB |
Output is correct - L* = 40 |
20 |
Correct |
24 ms |
2692 KB |
Output is correct - L* = 40 |
21 |
Correct |
24 ms |
2748 KB |
Output is correct - L* = 40 |
22 |
Correct |
24 ms |
2772 KB |
Output is correct - L* = 40 |
23 |
Correct |
24 ms |
2772 KB |
Output is correct - L* = 40 |
24 |
Correct |
26 ms |
2836 KB |
Output is correct - L* = 40 |
25 |
Correct |
26 ms |
2860 KB |
Output is correct - L* = 40 |
26 |
Correct |
26 ms |
2784 KB |
Output is correct - L* = 40 |
27 |
Correct |
24 ms |
2772 KB |
Output is correct - L* = 40 |
28 |
Correct |
24 ms |
2748 KB |
Output is correct - L* = 40 |
29 |
Correct |
24 ms |
2720 KB |
Output is correct - L* = 40 |
30 |
Correct |
27 ms |
2752 KB |
Output is correct - L* = 40 |
31 |
Correct |
24 ms |
2744 KB |
Output is correct - L* = 40 |
32 |
Correct |
25 ms |
2860 KB |
Output is correct - L* = 40 |
33 |
Correct |
25 ms |
2680 KB |
Output is correct - L* = 40 |
34 |
Correct |
27 ms |
2772 KB |
Output is correct - L* = 40 |
35 |
Correct |
25 ms |
2832 KB |
Output is correct - L* = 40 |
36 |
Correct |
25 ms |
2776 KB |
Output is correct - L* = 40 |
37 |
Correct |
35 ms |
2856 KB |
Output is correct - L* = 40 |
38 |
Correct |
25 ms |
2848 KB |
Output is correct - L* = 40 |
39 |
Correct |
27 ms |
2736 KB |
Output is correct - L* = 40 |
40 |
Correct |
26 ms |
2864 KB |
Output is correct - L* = 40 |