Submission #1123674

#TimeUsernameProblemLanguageResultExecution timeMemory
1123674math_rabbit_1028Message (IOI24_message)C++20
Compilation error
0 ms0 KiB
#include "message.h" using namespace std; vector<bool> add_blank(vector<bool> A, vector<bool> C) { vector<bool> ret; reverse(A.begin(), A.end()); for (int i = 0; i < 31; i++) { if (C[i]) ret.push_back(0); else { ret.push_back(A.back()); A.pop_back(); } } assert(A.empty()); return ret; } void send_message(vector<bool> M, vector<bool> C) { int S = (int)(M.size()); vector<bool> T(31, 1), F(31, 0); for (int i = 0; i < 30; i++) { if (C[i]) send_packet(T); else send_packet(F); } for (int i = 0; i < S; i += 16) { vector<bool> A(16, 0); for (int j = 0; j < 16; j++) { A[j] = (i+j < S) ? M[i+j] : 0; } send_packet(add_blank(A, C)); } vector<bool> A(16, 0); for (int j = 0; j < 16; j++) { if (j < S%16) A[j] = 1; else A[j] = 0; } send_packet(add_blank(A, C)); } vector<bool> rem_blank(vector<bool> A, vector<bool> C) { vector<bool> ret; for (int i = 0; i < 31; i++) { if (C[i]) continue; else { ret.push_back(A[i]); } } assert(ret.size() == 16); return ret; } vector<bool> receive_message(vector<vector<bool>> R) { vector<bool> C(31, 0); for (int i = 0; i < 30; i++) { vector<bool> V = R[i]; int a = 0, b = 0; // 0 - 1 for (int i = 0; i < 31; i++) { if (V[i]) b++; else a++; } if (a > b) C[i] = 0; else C[i] = 1; } int a = 0, b = 0; // 0 - 1 for (int i = 0; i < 30; i++) { if (C[i]) b++; else a++; } if (a < 16) C[30] = 0; else C[30] = 1; vector<bool> ret; for (int i = 30; i < R.size()-1; i++) { vector<bool> V = rem_blank(R[i], C); for (int j = 0; j < 16; j++) ret.push_back(V[j]); } vector<bool> V = rem_blank(R.back(), C); for (int i = 0; i < 16; i++) { if (!V[i]) ret.pop_back(); } return ret; }

Compilation message (stderr)

message.cpp: In function 'std::vector<bool> add_blank(std::vector<bool>, std::vector<bool>)':
message.cpp:14:9: error: 'assert' was not declared in this scope
   14 |         assert(A.empty());
      |         ^~~~~~
message.cpp:2:1: note: 'assert' is defined in header '<cassert>'; did you forget to '#include <cassert>'?
    1 | #include "message.h"
  +++ |+#include <cassert>
    2 | using namespace std;
message.cpp: In function 'std::vector<bool> rem_blank(std::vector<bool>, std::vector<bool>)':
message.cpp:50:9: error: 'assert' was not declared in this scope
   50 |         assert(ret.size() == 16);
      |         ^~~~~~
message.cpp:50:9: note: 'assert' is defined in header '<cassert>'; did you forget to '#include <cassert>'?