/* https://www.ioi-jp.org/camp/2022/2022-sp-tasks/contest3/device2-review.pdf */
#include "Anna.h"
#include <vector>
using namespace std;
typedef vector<int> vi;
const int L = 180;
namespace {
long long f(int l) {
return 1LL << (l + 2) / 3;
}
}
int Declare() {
return L;
}
pair<vi, vi> Anna(long long x) {
x--;
int l = 1;
while (x >= f(l))
x -= f(l++);
vi aa(l, 0), bb(l, 0);
for (int i = 0; i < l; i++)
aa[i] = x >> i / 3 & 1, bb[i] = i % 2;
return make_pair(aa, bb);
}
/* https://www.ioi-jp.org/camp/2022/2022-sp-tasks/contest3/device2-review.pdf */
#include "Bruno.h"
#include <vector>
using namespace std;
typedef vector<int> vi;
const int L = 180;
namespace {
long long f(int l) {
return 1LL << (l + 2) / 3;
}
}
int dd[L * 2];
long long Bruno(vi cc) {
int l = cc.size() / 2;
long long x = 1;
for (int l_ = 1; l_ < l; l_++)
x += f(l_);
int k = 0;
for (int i = 0; i < l * 2; i++)
if (cc[i] == 1)
k++;
k -= l / 2;
for (int i = 0, d = 0; i < l * 2; i++)
if (cc[i] == 0)
dd[i] = d++;
else
dd[i] = --d;
vi aa;
int l_ = l, i = 0, d = 0;
while (1) {
if (k == 0) {
while (l_ > 0)
aa.push_back(0), l_--;
break;
}
if (k == l_) {
while (l_ > 0)
aa.push_back(1), l_--;
break;
}
while (1)
if (dd[i] == d * 3 + 2) {
aa.push_back(0), aa.push_back(0), aa.push_back(0);
l_ -= 3, d++;
break;
} else if (dd[i] == d * 3 - 2) {
aa.push_back(1), aa.push_back(1), aa.push_back(1);
k -= 3, l_ -= 3, d--;
break;
} else
i++;
}
for (int i = 0; i < l; i += 3)
if (aa[i])
x += 1LL << i / 3;
return x;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
520 KB |
Output is correct |
2 |
Correct |
19 ms |
844 KB |
Output is correct |
3 |
Correct |
18 ms |
1068 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
520 KB |
Output is correct |
2 |
Correct |
19 ms |
844 KB |
Output is correct |
3 |
Correct |
18 ms |
1068 KB |
Output is correct |
4 |
Correct |
35 ms |
1480 KB |
Output is correct |
5 |
Correct |
36 ms |
1316 KB |
Output is correct |
6 |
Correct |
33 ms |
1540 KB |
Output is correct |
7 |
Correct |
31 ms |
1628 KB |
Output is correct |
8 |
Correct |
30 ms |
1460 KB |
Output is correct |
9 |
Correct |
36 ms |
1520 KB |
Output is correct |
10 |
Correct |
38 ms |
1448 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
520 KB |
Output is correct |
2 |
Correct |
19 ms |
844 KB |
Output is correct |
3 |
Correct |
18 ms |
1068 KB |
Output is correct |
4 |
Correct |
35 ms |
1480 KB |
Output is correct |
5 |
Correct |
36 ms |
1316 KB |
Output is correct |
6 |
Correct |
33 ms |
1540 KB |
Output is correct |
7 |
Correct |
31 ms |
1628 KB |
Output is correct |
8 |
Correct |
30 ms |
1460 KB |
Output is correct |
9 |
Correct |
36 ms |
1520 KB |
Output is correct |
10 |
Correct |
38 ms |
1448 KB |
Output is correct |
11 |
Correct |
32 ms |
1448 KB |
Output is correct |
12 |
Correct |
39 ms |
1552 KB |
Output is correct |
13 |
Correct |
34 ms |
1608 KB |
Output is correct |
14 |
Correct |
36 ms |
1536 KB |
Output is correct |
15 |
Correct |
34 ms |
1452 KB |
Output is correct |
16 |
Correct |
31 ms |
1596 KB |
Output is correct |
17 |
Correct |
33 ms |
1600 KB |
Output is correct |
18 |
Correct |
30 ms |
1332 KB |
Output is correct |
19 |
Correct |
31 ms |
1396 KB |
Output is correct |
20 |
Correct |
31 ms |
1316 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
520 KB |
Output is correct |
2 |
Correct |
19 ms |
844 KB |
Output is correct |
3 |
Correct |
18 ms |
1068 KB |
Output is correct |
4 |
Correct |
35 ms |
1480 KB |
Output is correct |
5 |
Correct |
36 ms |
1316 KB |
Output is correct |
6 |
Correct |
33 ms |
1540 KB |
Output is correct |
7 |
Correct |
31 ms |
1628 KB |
Output is correct |
8 |
Correct |
30 ms |
1460 KB |
Output is correct |
9 |
Correct |
36 ms |
1520 KB |
Output is correct |
10 |
Correct |
38 ms |
1448 KB |
Output is correct |
11 |
Correct |
32 ms |
1448 KB |
Output is correct |
12 |
Correct |
39 ms |
1552 KB |
Output is correct |
13 |
Correct |
34 ms |
1608 KB |
Output is correct |
14 |
Correct |
36 ms |
1536 KB |
Output is correct |
15 |
Correct |
34 ms |
1452 KB |
Output is correct |
16 |
Correct |
31 ms |
1596 KB |
Output is correct |
17 |
Correct |
33 ms |
1600 KB |
Output is correct |
18 |
Correct |
30 ms |
1332 KB |
Output is correct |
19 |
Correct |
31 ms |
1396 KB |
Output is correct |
20 |
Correct |
31 ms |
1316 KB |
Output is correct |
21 |
Correct |
36 ms |
1628 KB |
Output is correct |
22 |
Correct |
36 ms |
1800 KB |
Output is correct |
23 |
Correct |
38 ms |
1672 KB |
Output is correct |
24 |
Correct |
44 ms |
1764 KB |
Output is correct |
25 |
Correct |
50 ms |
1648 KB |
Output is correct |
26 |
Correct |
37 ms |
1736 KB |
Output is correct |
27 |
Correct |
37 ms |
1800 KB |
Output is correct |
28 |
Correct |
32 ms |
1500 KB |
Output is correct |
29 |
Correct |
33 ms |
1448 KB |
Output is correct |
30 |
Correct |
34 ms |
1528 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
520 KB |
Output is correct |
2 |
Correct |
19 ms |
844 KB |
Output is correct |
3 |
Correct |
18 ms |
1068 KB |
Output is correct |
4 |
Correct |
35 ms |
1480 KB |
Output is correct |
5 |
Correct |
36 ms |
1316 KB |
Output is correct |
6 |
Correct |
33 ms |
1540 KB |
Output is correct |
7 |
Correct |
31 ms |
1628 KB |
Output is correct |
8 |
Correct |
30 ms |
1460 KB |
Output is correct |
9 |
Correct |
36 ms |
1520 KB |
Output is correct |
10 |
Correct |
38 ms |
1448 KB |
Output is correct |
11 |
Correct |
32 ms |
1448 KB |
Output is correct |
12 |
Correct |
39 ms |
1552 KB |
Output is correct |
13 |
Correct |
34 ms |
1608 KB |
Output is correct |
14 |
Correct |
36 ms |
1536 KB |
Output is correct |
15 |
Correct |
34 ms |
1452 KB |
Output is correct |
16 |
Correct |
31 ms |
1596 KB |
Output is correct |
17 |
Correct |
33 ms |
1600 KB |
Output is correct |
18 |
Correct |
30 ms |
1332 KB |
Output is correct |
19 |
Correct |
31 ms |
1396 KB |
Output is correct |
20 |
Correct |
31 ms |
1316 KB |
Output is correct |
21 |
Correct |
36 ms |
1628 KB |
Output is correct |
22 |
Correct |
36 ms |
1800 KB |
Output is correct |
23 |
Correct |
38 ms |
1672 KB |
Output is correct |
24 |
Correct |
44 ms |
1764 KB |
Output is correct |
25 |
Correct |
50 ms |
1648 KB |
Output is correct |
26 |
Correct |
37 ms |
1736 KB |
Output is correct |
27 |
Correct |
37 ms |
1800 KB |
Output is correct |
28 |
Correct |
32 ms |
1500 KB |
Output is correct |
29 |
Correct |
33 ms |
1448 KB |
Output is correct |
30 |
Correct |
34 ms |
1528 KB |
Output is correct |
31 |
Correct |
50 ms |
2200 KB |
Output is correct |
32 |
Correct |
52 ms |
2252 KB |
Output is correct |
33 |
Correct |
55 ms |
2292 KB |
Output is correct |
34 |
Correct |
52 ms |
2256 KB |
Output is correct |
35 |
Correct |
48 ms |
2216 KB |
Output is correct |
36 |
Correct |
67 ms |
2128 KB |
Output is correct |
37 |
Correct |
48 ms |
2192 KB |
Output is correct |
38 |
Correct |
54 ms |
2052 KB |
Output is correct |
39 |
Correct |
46 ms |
2116 KB |
Output is correct |
40 |
Correct |
41 ms |
2100 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
87 ms |
3384 KB |
Output is partially correct |
2 |
Partially correct |
81 ms |
3268 KB |
Output is partially correct |
3 |
Partially correct |
78 ms |
3420 KB |
Output is partially correct |
4 |
Partially correct |
80 ms |
3324 KB |
Output is partially correct |
5 |
Partially correct |
86 ms |
3172 KB |
Output is partially correct |
6 |
Partially correct |
81 ms |
3296 KB |
Output is partially correct |
7 |
Partially correct |
79 ms |
3328 KB |
Output is partially correct |
8 |
Partially correct |
77 ms |
3308 KB |
Output is partially correct |
9 |
Partially correct |
76 ms |
3348 KB |
Output is partially correct |
10 |
Partially correct |
91 ms |
3460 KB |
Output is partially correct |
11 |
Partially correct |
76 ms |
3328 KB |
Output is partially correct |
12 |
Partially correct |
79 ms |
3180 KB |
Output is partially correct |
13 |
Partially correct |
82 ms |
3432 KB |
Output is partially correct |
14 |
Partially correct |
80 ms |
3344 KB |
Output is partially correct |
15 |
Partially correct |
69 ms |
3172 KB |
Output is partially correct |
16 |
Partially correct |
77 ms |
3076 KB |
Output is partially correct |
17 |
Partially correct |
77 ms |
3088 KB |
Output is partially correct |
18 |
Partially correct |
77 ms |
3144 KB |
Output is partially correct |
19 |
Partially correct |
66 ms |
3172 KB |
Output is partially correct |
20 |
Partially correct |
66 ms |
3156 KB |
Output is partially correct |