#include "Anna.h"
#include <vector>
#include <string>
using namespace std;
///log_3(2^N) +17 bits?
void Anna(int N, std::vector<char> S) {
int Xpos = -1;
int Zpos = -1;
for (int x = 0; x<N; x++){
if (S[x]=='Z') Zpos = x;
if (Xpos==-1 && S[x]=='X') Xpos = x;
}
for (int x = 16; x>=0; x--){
Send((bool)(Xpos&(1<<x)));
}
while (S.size()%10!=(Xpos+1)%10){
S.push_back('X');
}
for (int x = Xpos+1; x<N; x+=10){
int state = 0;
for (int y = 0; y<10; y+=2){
string t = "";
t.push_back(S[x+y]);
t.push_back(S[x+y+1]);
vector<string> opt0 = {"XX","XY","YX","YY"};
vector<string> opt1 = {"XZ","YZ","ZZ"};
vector<string> opt2 = {"ZX","ZY"};
state *= 3;
for (auto x : opt0){
if (x==t) state += 0;
}
for (auto x : opt1){
if (x==t) state += 1;
}
for (auto x : opt2){
if (x==t) state += 2;
}
}
for (int x = 7; x>=0; x--){
if (state&(1<<x)){
Send(1);
}
else Send(0);
}
}
}
#include "Bruno.h"
#include <vector>
#include <cassert>
#include <algorithm>
using namespace std;
void Bruno(int N, int L, std::vector<int> A) {
// assert(L==N+17);
int Xpos = 0;
int Zpos = 0;
for (int x = 0; x<17; x++){
Xpos = (Xpos<<1)+A[x];
}
if (Xpos==(1<<17)-1){
for (int x = 0; x<N; x++){
Remove(x);
}
return;
}
vector<int> rem;
for (int x = 0; x<Xpos; x++){
Remove(x);
}
int c = Xpos+1;
for (int x = 17; x<A.size(); x+=8){
int state = 0;
for (int y = 0; y<8; y++){
state <<=1;
state += A[x+y];
}
vector<int> things;
for (int x = 0; x<5; x++){
things.push_back(state%3);
state /= 3;
}
reverse(things.begin(),things.end());
for (int y = 0; y<5; y++){
if (things[y]==0){
rem.push_back(c+2*y);
rem.push_back(c+2*y+1);
}
else if (things[y]==1){
Remove(c+2*y);
while (!rem.empty()){
Remove(rem.back());
rem.pop_back();
}
Remove(c+y*2+1);
}
else if (things[y]==2){
while (!rem.empty()){
Remove(rem.back());
rem.pop_back();
}
Remove(c+2*y);
rem.push_back(c+y*2+1);
}
}
c+=10;
}
Remove(Xpos);
for (auto x : rem){
if (x<N)
Remove(x);
}
}
Compilation message
Anna.cpp: In function 'void Anna(int, std::vector<char>)':
Anna.cpp:18:23: warning: comparison of integer expressions of different signedness: 'std::vector<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
18 | while (S.size()%10!=(Xpos+1)%10){
| ~~~~~~~~~~~^~~~~~~~~~~~~
Anna.cpp:10:9: warning: variable 'Zpos' set but not used [-Wunused-but-set-variable]
10 | int Zpos = -1;
| ^~~~
Bruno.cpp: In function 'void Bruno(int, int, std::vector<int>)':
Bruno.cpp:27:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
27 | for (int x = 17; x<A.size(); x+=8){
| ~^~~~~~~~~
Bruno.cpp:11:9: warning: unused variable 'Zpos' [-Wunused-variable]
11 | int Zpos = 0;
| ^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
492 KB |
Output is correct |
2 |
Correct |
0 ms |
488 KB |
Output is correct |
3 |
Correct |
0 ms |
560 KB |
Output is correct |
4 |
Correct |
0 ms |
436 KB |
Output is correct |
5 |
Correct |
0 ms |
496 KB |
Output is correct |
6 |
Correct |
0 ms |
488 KB |
Output is correct |
7 |
Correct |
0 ms |
488 KB |
Output is correct |
8 |
Correct |
0 ms |
488 KB |
Output is correct |
9 |
Correct |
0 ms |
496 KB |
Output is correct |
10 |
Correct |
0 ms |
488 KB |
Output is correct |
11 |
Correct |
0 ms |
484 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
81 ms |
7876 KB |
Partially correct |
2 |
Partially correct |
80 ms |
7936 KB |
Partially correct |
3 |
Partially correct |
79 ms |
7864 KB |
Partially correct |
4 |
Partially correct |
80 ms |
7908 KB |
Partially correct |
5 |
Partially correct |
79 ms |
7824 KB |
Partially correct |
6 |
Partially correct |
87 ms |
7928 KB |
Partially correct |
7 |
Partially correct |
78 ms |
7916 KB |
Partially correct |
8 |
Partially correct |
79 ms |
7952 KB |
Partially correct |
9 |
Partially correct |
81 ms |
8092 KB |
Partially correct |
10 |
Partially correct |
77 ms |
7904 KB |
Partially correct |
11 |
Partially correct |
79 ms |
7968 KB |
Partially correct |
12 |
Partially correct |
78 ms |
7856 KB |
Partially correct |
13 |
Partially correct |
84 ms |
8108 KB |
Partially correct |
14 |
Partially correct |
84 ms |
7972 KB |
Partially correct |
15 |
Partially correct |
84 ms |
7924 KB |
Partially correct |
16 |
Partially correct |
90 ms |
7936 KB |
Partially correct |
17 |
Partially correct |
87 ms |
8140 KB |
Partially correct |
18 |
Partially correct |
81 ms |
7820 KB |
Partially correct |
19 |
Partially correct |
89 ms |
7748 KB |
Partially correct |
20 |
Partially correct |
80 ms |
7924 KB |
Partially correct |
21 |
Partially correct |
82 ms |
8004 KB |
Partially correct |
22 |
Partially correct |
89 ms |
8076 KB |
Partially correct |
23 |
Partially correct |
79 ms |
7976 KB |
Partially correct |
24 |
Partially correct |
78 ms |
7840 KB |
Partially correct |
25 |
Partially correct |
81 ms |
7876 KB |
Partially correct |
26 |
Partially correct |
82 ms |
8128 KB |
Partially correct |
27 |
Correct |
51 ms |
6740 KB |
Output is correct |
28 |
Partially correct |
82 ms |
8108 KB |
Partially correct |
29 |
Partially correct |
82 ms |
7796 KB |
Partially correct |
30 |
Correct |
51 ms |
6640 KB |
Output is correct |
31 |
Partially correct |
81 ms |
7828 KB |
Partially correct |
32 |
Partially correct |
78 ms |
8028 KB |
Partially correct |
33 |
Partially correct |
77 ms |
7872 KB |
Partially correct |