#include "Annalib.h"
#include <bits/stdc++.h>
using namespace std;
void Anna(int N, long long X, int K, int P[])
{
map<vector<int>, vector<int>> M;
M[{1, 1}] = {1, 1, 1};
M[{1}] = {1, 1, 0};
M[{1, 0}] = {1, 0, 1};
M[{0}] = {1, 0, 0};
M[{0, 1}] = {0, 1, 1};
M[{0, 0}] = {0, 1, 0};
vector<int> P2(N);
for (int i = 0; i < K; i++)
P2[P[i]] = 1;
vector<int> ans(N);
int buff = 0;
vector<int> bits;
while (X)
{
bits.push_back(X % 2);
X /= 2;
}
reverse(bits.begin(), bits.end());
for (int i = 0; i < N; i += 3)
{
if (buff == bits.size())
break;
vector<int> temp;
if (P2[i] + P2[i + 1] + P2[i + 2] > 1)
continue;
if (P2[i] == 1)
{
if (bits[buff] == 1)
{
temp = {0, 0, 1};
buff++;
}
else if (buff < bits.size() - 1 && bits[buff] == 0)
{
temp = M[{bits[buff], bits[buff + 1]}];
buff += 2;
}
}
else if (P2[i + 1] == 1)
{
if (bits[buff] == 1)
temp = {0, 0, 1};
else
temp = {1, 0, 0};
buff++;
}
else if (P2[i + 2] == 1)
{
if (bits[buff] == 1)
temp = {1, 1, 0};
else
temp = {1, 0, 0};
}
else
{
if (buff < bits.size() - 1)
{
temp = M[{bits[buff], bits[buff + 1]}];
buff += 2;
}
else
{
temp = M[{bits[buff]}];
buff++;
}
}
if (!temp.empty())
ans[i] = temp[0], ans[i + 1] = temp[1], ans[i + 2] = temp[2];
}
for (int i = 0; i < N; i++)
{
// cout << ans[i] << ' ';
Set(i, ans[i]);
}
}
/*int main()
{
long long N, X, K;
cin >> N >> X >> K;
long long P[N];
srand(time(0));
for (long long i = 0; i < K; i++)
P[i] = rand() % N;
Anna(N, X, K, P);
}*/
#include "Brunolib.h"
#include <bits/stdc++.h>
using namespace std;
long long Bruno(int N, int A[])
{
map<vector<int>, vector<int>> M;
M[{1, 1, 1}] = {1, 1};
M[{1, 1, 0}] = {1};
M[{1, 0, 1}] = {1, 0};
M[{1, 0, 0}] = {0};
M[{0, 1, 1}] = {0, 1};
M[{0, 1, 0}] = {0, 0};
M[{0, 0, 1}] = {1};
long long X = 0;
for (int i = 0; i < N; i += 3)
{
vector<int> temp = {A[i], A[i + 1], A[i + 2]};
if (temp[0] + temp[1] + temp[2] == 0)
continue;
else
temp = M[temp];
for (int j = 0; j < temp.size(); j++)
{
X *= 2;
X += temp[j];
}
}
return X;
}
/*int main()
{
int N;
cin >> N;
int A[N];
for (int i = 0; i < N; i++)
cin >> A[i];
cout << Bruno(N, A);
}*/
Compilation message
Anna.cpp: In function 'void Anna(int, long long int, int, int*)':
Anna.cpp:28:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
28 | if (buff == bits.size())
| ~~~~~^~~~~~~~~~~~~~
Anna.cpp:40:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
40 | else if (buff < bits.size() - 1 && bits[buff] == 0)
| ~~~~~^~~~~~~~~~~~~~~~~
Anna.cpp:63:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
63 | if (buff < bits.size() - 1)
| ~~~~~^~~~~~~~~~~~~~~~~
Bruno.cpp: In function 'long long int Bruno(int, int*)':
Bruno.cpp:22:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
22 | for (int j = 0; j < temp.size(); j++)
| ~~^~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
25 ms |
2640 KB |
Output isn't correct - L* = 0 |
2 |
Partially correct |
26 ms |
2676 KB |
Output isn't correct - L* = 0 |
3 |
Partially correct |
24 ms |
2668 KB |
Output isn't correct - L* = 0 |
4 |
Partially correct |
26 ms |
2736 KB |
Output isn't correct - L* = 0 |
5 |
Partially correct |
27 ms |
2724 KB |
Output isn't correct - L* = 0 |
6 |
Partially correct |
25 ms |
2748 KB |
Output isn't correct - L* = 0 |
7 |
Partially correct |
24 ms |
2668 KB |
Output isn't correct - L* = 0 |
8 |
Partially correct |
24 ms |
2760 KB |
Output isn't correct - L* = 0 |
9 |
Partially correct |
28 ms |
2728 KB |
Output isn't correct - L* = 0 |
10 |
Partially correct |
25 ms |
2728 KB |
Output isn't correct - L* = 0 |
11 |
Partially correct |
24 ms |
2748 KB |
Output isn't correct - L* = 0 |
12 |
Partially correct |
24 ms |
2752 KB |
Output isn't correct - L* = 0 |
13 |
Partially correct |
24 ms |
2700 KB |
Output isn't correct - L* = 0 |
14 |
Partially correct |
31 ms |
2412 KB |
Output isn't correct - L* = 0 |
15 |
Partially correct |
25 ms |
2756 KB |
Output isn't correct - L* = 0 |
16 |
Partially correct |
30 ms |
2568 KB |
Output isn't correct - L* = 0 |
17 |
Partially correct |
24 ms |
2716 KB |
Output isn't correct - L* = 0 |
18 |
Partially correct |
24 ms |
2720 KB |
Output isn't correct - L* = 0 |
19 |
Partially correct |
27 ms |
2664 KB |
Output isn't correct - L* = 0 |
20 |
Partially correct |
25 ms |
2860 KB |
Output isn't correct - L* = 0 |
21 |
Partially correct |
28 ms |
2720 KB |
Output isn't correct - L* = 0 |
22 |
Partially correct |
24 ms |
2700 KB |
Output isn't correct - L* = 0 |
23 |
Partially correct |
24 ms |
2740 KB |
Output isn't correct - L* = 0 |
24 |
Partially correct |
28 ms |
2528 KB |
Output isn't correct - L* = 0 |
25 |
Partially correct |
24 ms |
2736 KB |
Output isn't correct - L* = 0 |
26 |
Partially correct |
24 ms |
2840 KB |
Output isn't correct - L* = 0 |
27 |
Partially correct |
25 ms |
2660 KB |
Output isn't correct - L* = 0 |
28 |
Partially correct |
24 ms |
2724 KB |
Output isn't correct - L* = 0 |
29 |
Partially correct |
26 ms |
2700 KB |
Output isn't correct - L* = 0 |
30 |
Partially correct |
25 ms |
2800 KB |
Output isn't correct - L* = 0 |
31 |
Partially correct |
28 ms |
2724 KB |
Output isn't correct - L* = 0 |
32 |
Partially correct |
25 ms |
2664 KB |
Output isn't correct - L* = 0 |
33 |
Partially correct |
26 ms |
2756 KB |
Output isn't correct - L* = 0 |
34 |
Partially correct |
27 ms |
2912 KB |
Output isn't correct - L* = 0 |
35 |
Partially correct |
25 ms |
2724 KB |
Output isn't correct - L* = 0 |
36 |
Partially correct |
25 ms |
2752 KB |
Output isn't correct - L* = 0 |
37 |
Partially correct |
25 ms |
2824 KB |
Output isn't correct - L* = 0 |
38 |
Partially correct |
24 ms |
2720 KB |
Output isn't correct - L* = 0 |
39 |
Partially correct |
25 ms |
2668 KB |
Output isn't correct - L* = 0 |
40 |
Partially correct |
24 ms |
2756 KB |
Output isn't correct - L* = 0 |