#include "Annalib.h"
#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int>> prs = {{4, 28}, {118, 69}, {138, 85}, {30, 65}, {63, 35}, {132, 146}, {56, 10}, {95, 74}, {64, 70}, {125, 128}, {124, 39}, {120, 111}, {80, 29}, {16, 60}, {53, 100}, {26, 136}, {106, 143}, {137, 76}, {123, 45}, {37, 33}, {130, 3}, {2, 59}, {99, 142}, {145, 97}, {68, 83}, {127, 58}, {38, 1}, {62, 114}, {43, 101}, {22, 141}, {103, 131}, {110, 18}, {61, 49}, {115, 0}, {5, 135}, {15, 13}, {86, 34}, {105, 72}, {9, 7}, {126, 88}, {77, 41}, {17, 51}, {133, 50}, {81, 112}, {116, 67}, {96, 24}, {148, 117}, {84, 102}, {144, 19}, {92, 121}, {25, 8}, {75, 52}, {93, 73}, {149, 6}, {20, 48}, {104, 66}, {12, 57}, {91, 147}, {90, 82}, {98, 27}, {21, 139}, {129, 108}, {44, 31}, {89, 134}, {14, 87}, {32, 71}, {55, 122}, {23, 79}, {36, 109}, {78, 113}, {119, 47}, {107, 54}, {42, 40}, {46, 11}, {140, 94}};
vector<vector<int>> lol = {{2,0,1},{1,0,2},{1,2,0},{0,1,2},{2,0,1},{1,0,2},{1,0,2},{2,1,0},{1,0,2},{2,1,0},{0,1,2},{2,1,0},{0,2,1},{1,0,2},{2,1,0},{1,0,2},{2,0,1},{1,0,2},{0,2,1},{0,2,1},{0,1,2},{2,0,1},{0,2,1},{0,1,2},{2,0,1},{2,0,1},{0,2,1},{1,2,0},{0,2,1},{0,1,2},{2,1,0},{0,2,1},{2,0,1},{1,0,2},{2,1,0},{0,1,2},{1,0,2},{2,1,0}};
void Anna( int N, long long X, int K, int P[] ){
vector<int> used(N, 0);
for (int i = 0; i < K; i++) used[P[i]] = 1;
vector<int> bits;
for (int i = 0; i < 38; i++) {
bits.push_back(X % 3);
X /= 3;
}
reverse(bits.begin(), bits.end());
int cb = 0;
for (int i = 0; i < prs.size(); i++) {
if (cb >= 38) {
Set(prs[i].first,0);
Set(prs[i].second,0);continue;
}
if (used[prs[i].first] && used[prs[i].second]) {
Set(prs[i].first,0);Set(prs[i].second,0);continue;
}
int ps = 0;
for (int j = 0; j < 3; j++) {
if (lol[cb][j] == bits[cb]) ps = j;
}
if (used[prs[i].first]) {
if (ps != 0) {
Set(prs[i].first,0);Set(prs[i].second,0);continue;
}
Set(prs[i].second, 1);
Set(prs[i].first,0);
cb++;
} else if (used[prs[i].second]) {
if (ps != 1) {
Set(prs[i].first,0);Set(prs[i].second,0);continue;
}
Set(prs[i].first, 1);
Set(prs[i].second, 0);
cb++;
} else {
Set(prs[i].second, 1 - ps % 2);
Set(prs[i].first, (ps > 0));
cb++;
}
}
}
#include "Brunolib.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
vector<pair<int, int>> prs = {{4, 28}, {118, 69}, {138, 85}, {30, 65}, {63, 35}, {132, 146}, {56, 10}, {95, 74}, {64, 70}, {125, 128}, {124, 39}, {120, 111}, {80, 29}, {16, 60}, {53, 100}, {26, 136}, {106, 143}, {137, 76}, {123, 45}, {37, 33}, {130, 3}, {2, 59}, {99, 142}, {145, 97}, {68, 83}, {127, 58}, {38, 1}, {62, 114}, {43, 101}, {22, 141}, {103, 131}, {110, 18}, {61, 49}, {115, 0}, {5, 135}, {15, 13}, {86, 34}, {105, 72}, {9, 7}, {126, 88}, {77, 41}, {17, 51}, {133, 50}, {81, 112}, {116, 67}, {96, 24}, {148, 117}, {84, 102}, {144, 19}, {92, 121}, {25, 8}, {75, 52}, {93, 73}, {149, 6}, {20, 48}, {104, 66}, {12, 57}, {91, 147}, {90, 82}, {98, 27}, {21, 139}, {129, 108}, {44, 31}, {89, 134}, {14, 87}, {32, 71}, {55, 122}, {23, 79}, {36, 109}, {78, 113}, {119, 47}, {107, 54}, {42, 40}, {46, 11}, {140, 94}};
vector<vector<int>> lol = {{2,0,1},{1,0,2},{1,2,0},{0,1,2},{2,0,1},{1,0,2},{1,0,2},{2,1,0},{1,0,2},{2,1,0},{0,1,2},{2,1,0},{0,2,1},{1,0,2},{2,1,0},{1,0,2},{2,0,1},{1,0,2},{0,2,1},{0,2,1},{0,1,2},{2,0,1},{0,2,1},{0,1,2},{2,0,1},{2,0,1},{0,2,1},{1,2,0},{0,2,1},{0,1,2},{2,1,0},{0,2,1},{2,0,1},{1,0,2},{2,1,0},{0,1,2},{1,0,2},{2,1,0}};
long long Bruno( int N, int A[] ){
int cb = 0;
ll ans = 0;
for (int i = 0; i < prs.size() && cb < 38; i++) {
if (A[prs[i].first] + A[prs[i].second] == 0) continue;
if (!A[prs[i].first]) {
ans = ans * 3ll + lol[cb++][0];
} else if (!A[prs[i].second]) {
ans = ans * 3ll + lol[cb++][1];
} else {
ans = ans * 3ll + lol[cb++][2];
}
}
return ans;
}
Compilation message
Anna.cpp: In function 'void Anna(int, long long int, int, int*)':
Anna.cpp:19:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
19 | for (int i = 0; i < prs.size(); i++) {
| ~~^~~~~~~~~~~~
Bruno.cpp: In function 'long long int Bruno(int, int*)':
Bruno.cpp:13:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
13 | for (int i = 0; i < prs.size() && cb < 38; i++) {
| ~~^~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
20 ms |
2772 KB |
Output is correct - L* = 40 |
2 |
Correct |
22 ms |
2764 KB |
Output is correct - L* = 40 |
3 |
Correct |
24 ms |
2768 KB |
Output is correct - L* = 40 |
4 |
Correct |
23 ms |
2772 KB |
Output is correct - L* = 40 |
5 |
Correct |
22 ms |
2776 KB |
Output is correct - L* = 40 |
6 |
Correct |
23 ms |
2776 KB |
Output is correct - L* = 40 |
7 |
Correct |
24 ms |
2868 KB |
Output is correct - L* = 40 |
8 |
Correct |
29 ms |
2868 KB |
Output is correct - L* = 40 |
9 |
Correct |
23 ms |
2824 KB |
Output is correct - L* = 40 |
10 |
Correct |
26 ms |
2784 KB |
Output is correct - L* = 40 |
11 |
Correct |
20 ms |
2776 KB |
Output is correct - L* = 40 |
12 |
Correct |
20 ms |
2784 KB |
Output is correct - L* = 40 |
13 |
Correct |
22 ms |
2776 KB |
Output is correct - L* = 40 |
14 |
Correct |
22 ms |
2768 KB |
Output is correct - L* = 40 |
15 |
Correct |
24 ms |
2864 KB |
Output is correct - L* = 40 |
16 |
Correct |
26 ms |
2752 KB |
Output is correct - L* = 40 |
17 |
Correct |
20 ms |
2768 KB |
Output is correct - L* = 40 |
18 |
Correct |
22 ms |
2768 KB |
Output is correct - L* = 40 |
19 |
Correct |
20 ms |
2776 KB |
Output is correct - L* = 40 |
20 |
Correct |
22 ms |
2772 KB |
Output is correct - L* = 40 |
21 |
Correct |
23 ms |
2780 KB |
Output is correct - L* = 40 |
22 |
Correct |
24 ms |
2776 KB |
Output is correct - L* = 40 |
23 |
Correct |
26 ms |
2740 KB |
Output is correct - L* = 40 |
24 |
Correct |
22 ms |
2852 KB |
Output is correct - L* = 40 |
25 |
Correct |
23 ms |
2752 KB |
Output is correct - L* = 40 |
26 |
Correct |
26 ms |
2688 KB |
Output is correct - L* = 40 |
27 |
Correct |
24 ms |
3284 KB |
Output is correct - L* = 40 |
28 |
Correct |
20 ms |
2776 KB |
Output is correct - L* = 40 |
29 |
Correct |
23 ms |
2772 KB |
Output is correct - L* = 40 |
30 |
Correct |
23 ms |
2752 KB |
Output is correct - L* = 40 |
31 |
Correct |
22 ms |
2772 KB |
Output is correct - L* = 40 |
32 |
Correct |
22 ms |
2868 KB |
Output is correct - L* = 40 |
33 |
Correct |
22 ms |
2808 KB |
Output is correct - L* = 40 |
34 |
Correct |
22 ms |
2896 KB |
Output is correct - L* = 40 |
35 |
Correct |
22 ms |
2772 KB |
Output is correct - L* = 40 |
36 |
Correct |
22 ms |
2780 KB |
Output is correct - L* = 40 |
37 |
Correct |
23 ms |
2776 KB |
Output is correct - L* = 40 |
38 |
Correct |
23 ms |
2744 KB |
Output is correct - L* = 40 |
39 |
Correct |
23 ms |
2772 KB |
Output is correct - L* = 40 |
40 |
Correct |
22 ms |
2752 KB |
Output is correct - L* = 40 |