#include <iostream>
#include <vector>
#include "Annalib.h"
using namespace std;
vector<vector<int>> motifs = {
{1, 1, 1},
{1, 1, 0},
{0, 1, 1},
{0, 0, 1},
{1, 0, 1},
{0, 1, 0},
{1, 0, 0},
{0, 0, 0}
};
vector<vector<int>> reponses = {
{1, 1},
{1, 0},
{0, 1},
{0, 0},
{1},
{1},
{0},
{}
};
void Anna(int N, long long X, int K, int P[]) {
vector<int> broken(N, 0);
for(int iBroken = 0;iBroken < K;iBroken++) {
broken[P[iBroken]] = 1;
}
vector<bool> number(1000, 0);
for(int iBit = 0;iBit < 60;iBit++) {
number[iBit] = X % 2;
X /= 2;
}
int it = 0;
for(int pos = 0;pos < N/3;pos++) {
for(int iMotif = 0;iMotif < 8;iMotif++) {
bool estValide = true;
for(int iBit = 0;iBit < 3;iBit++)
if(broken[3 * pos + iBit] == 1 && motifs[iMotif][iBit] == 1)
estValide = false;
for(int iBit = 0;iBit < reponses[iMotif].size();iBit++)
if(reponses[iMotif][iBit] != number[it + iBit])
estValide = false;
if(estValide) {
for(int iBit = 0;iBit < 3;iBit++) {
Set(3 * pos + iBit, motifs[iMotif][iBit]);
}
it += reponses[iMotif].size();
break;
}
}
}
for(int iBit = 3 * (N / 3);iBit < N;iBit++) {
Set(iBit, 0);
}
}
#include <iostream>
#include <vector>
#include "Brunolib.h"
using namespace std;
vector<vector<int>> motifs = {
{1, 1, 1},
{1, 1, 0},
{0, 1, 1},
{0, 0, 1},
{1, 0, 1},
{0, 1, 0},
{1, 0, 0},
{0, 0, 0}
};
vector<vector<int>> reponses = {
{1, 1},
{1, 0},
{0, 1},
{0, 0},
{1},
{1},
{0},
{}
};
long long Bruno(int N, int A[]) {
long long X = 0, exp = 1;
for(int pos = 0;pos < N / 3;pos++) {
for(int iMotif = 0;iMotif < 8;iMotif++) {
bool estValide = true;
for(int iBit = 0;iBit < 3;iBit++)
if(A[3 * pos + iBit] != motifs[iMotif][iBit])
estValide = false;
if(estValide) {
for(int bit : reponses[iMotif]) {
X += bit * exp;
exp *= 2;
}
}
}
}
return X;
}
Compilation message
Anna.cpp: In function 'void Anna(int, long long int, int, int*)':
Anna.cpp:50:29: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int iBit = 0;iBit < reponses[iMotif].size();iBit++)
~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
52 ms |
3312 KB |
Output is correct - L* = 40 |
2 |
Correct |
68 ms |
4072 KB |
Output is correct - L* = 40 |
3 |
Correct |
59 ms |
4136 KB |
Output is correct - L* = 40 |
4 |
Correct |
75 ms |
4640 KB |
Output is correct - L* = 40 |
5 |
Correct |
76 ms |
4640 KB |
Output is correct - L* = 40 |
6 |
Correct |
55 ms |
4904 KB |
Output is correct - L* = 40 |
7 |
Correct |
55 ms |
5120 KB |
Output is correct - L* = 40 |
8 |
Correct |
78 ms |
5592 KB |
Output is correct - L* = 40 |
9 |
Correct |
57 ms |
5592 KB |
Output is correct - L* = 40 |
10 |
Correct |
58 ms |
5768 KB |
Output is correct - L* = 40 |
11 |
Correct |
67 ms |
6288 KB |
Output is correct - L* = 40 |
12 |
Correct |
58 ms |
6288 KB |
Output is correct - L* = 40 |
13 |
Correct |
51 ms |
6416 KB |
Output is correct - L* = 40 |
14 |
Correct |
55 ms |
6632 KB |
Output is correct - L* = 40 |
15 |
Correct |
75 ms |
6856 KB |
Output is correct - L* = 40 |
16 |
Correct |
75 ms |
7064 KB |
Output is correct - L* = 40 |
17 |
Correct |
56 ms |
7448 KB |
Output is correct - L* = 40 |
18 |
Correct |
62 ms |
7472 KB |
Output is correct - L* = 40 |
19 |
Correct |
57 ms |
7680 KB |
Output is correct - L* = 40 |
20 |
Correct |
79 ms |
8152 KB |
Output is correct - L* = 40 |
21 |
Correct |
69 ms |
8152 KB |
Output is correct - L* = 40 |
22 |
Correct |
63 ms |
8320 KB |
Output is correct - L* = 40 |
23 |
Correct |
64 ms |
8528 KB |
Output is correct - L* = 40 |
24 |
Correct |
81 ms |
8984 KB |
Output is correct - L* = 40 |
25 |
Correct |
66 ms |
9256 KB |
Output is correct - L* = 40 |
26 |
Correct |
52 ms |
9256 KB |
Output is correct - L* = 40 |
27 |
Correct |
56 ms |
9384 KB |
Output is correct - L* = 40 |
28 |
Correct |
54 ms |
9600 KB |
Output is correct - L* = 40 |
29 |
Correct |
68 ms |
9808 KB |
Output is correct - L* = 40 |
30 |
Correct |
69 ms |
10016 KB |
Output is correct - L* = 40 |
31 |
Correct |
53 ms |
10488 KB |
Output is correct - L* = 40 |
32 |
Correct |
60 ms |
10832 KB |
Output is correct - L* = 40 |
33 |
Correct |
63 ms |
10832 KB |
Output is correct - L* = 40 |
34 |
Correct |
59 ms |
10864 KB |
Output is correct - L* = 40 |
35 |
Correct |
69 ms |
11328 KB |
Output is correct - L* = 40 |
36 |
Correct |
76 ms |
11328 KB |
Output is correct - L* = 40 |
37 |
Correct |
57 ms |
11592 KB |
Output is correct - L* = 40 |
38 |
Correct |
65 ms |
11848 KB |
Output is correct - L* = 40 |
39 |
Correct |
66 ms |
11928 KB |
Output is correct - L* = 40 |
40 |
Correct |
55 ms |
12136 KB |
Output is correct - L* = 40 |