Submission #1111036

#TimeUsernameProblemLanguageResultExecution timeMemory
1111036thieunguyenhuyMessage (IOI24_message)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define popcount(n) (__builtin_popcountll((n))) #define clz(n) (__builtin_clzll((n))) #define ctz(n) (__builtin_ctzll((n))) #define lg(n) (63 - __builtin_clzll((n))) #define BIT(n, i) (((n) >> (i)) & 1ll) #define MASK(i) (1ll << (i)) #define FLIP(n, i) ((n) ^ (1ll << (i))) #define ON(n, i) ((n) | MASK(i)) #define OFF(n, i) ((n) & ~MASK(i)) #define Int __int128 #define fi first #define se second typedef long long ll; typedef unsigned long long ull; typedef long double ld; typedef pair<int, int> pii; typedef pair<long long, long long> pll; typedef pair<long long, int> pli; typedef pair<int, long long> pil; typedef vector<pair<int, int>> vii; typedef vector<pair<long long, long long>> vll; typedef vector<pair<long long, int>> vli; typedef vector<pair<int, long long>> vil; template <class T1, class T2> bool maximize(T1 &x, T2 y) { if (x < y) { x = y; return true; } return false; } template <class T1, class T2> bool minimize(T1 &x, T2 y) { if (x > y) { x = y; return true; } return false; } template <class T> void remove_duplicate(vector<T> &ve) { sort (ve.begin(), ve.end()); ve.resize(unique(ve.begin(), ve.end()) - ve.begin()); } mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count()); template <class T> T random(T l, T r) { return uniform_int_distribution<T>(l, r)(rng); } template <class T> T random(T r) { return rng() % r; } const int N = 1e6 + 5; const int MOD = 1e9 + 7; const int inf = 1e9; const long long INF = 1e18; #ifdef hwe vector<bool> M, C; vector<vector<bool>> R; vector<bool> send_packet(vector<bool> A) { assert(A.size() == 31); for (int i = 0; i < 31; ++i) if (C[i] == 1) { A[i] = random(2); } R.emplace_back(A); return A; } #endif void send_message(vector<bool> M, vector<bool> C) { // send C for (int i = 0; i < 31; ++i) { send_packet(vector<bool>(31, C[i])); } vector<int> pos; for (int i = 0; i < 31; ++i) if (C[i] == 0) { pos.emplace_back(i); } assert(pos.size() == 16); // send M.size() vector<bool> packet(31, 0); int sz = M.size(); for (int i = 0; i < 16; ++i) { packet[pos[i]] = BIT(sz, i); } send_packet(packet); // send M for (int i = 0; i < sz; i += 16) { vector<bool> packet(31, 0); for (int j = i; j < min(sz, i + 16); ++j) packet[pos[j - i]] = M[j]; send_packet(packet); } } vector<bool> receive_message(vector<vector<bool>> R) { // receive C vector<bool> C(31, 0); for (int i = 0; i < 31; ++i) { vector<bool> packet = R[i]; int zeros = 0, ones = 0; for (auto x : packet) zeros += !x, ones += x; C[i] = (ones > zeros); } cerr << "Done C\n"; for (auto x : C) cerr << x; cerr << '\n'; vector<int> pos; for (int i = 0; i < 31; ++i) if (C[i] == 0) { pos.emplace_back(i); } assert(pos.size() == 16); // receive size vector<bool> packet = R[31]; int sz = 0; for (int i = 0; i < 16; ++i) if (packet[pos[i]]) { sz = ON(sz, i); } cerr << "Done sz " << sz << '\n'; // receive M vector<bool> M; M.reserve(sz); for (int i = 0; i < sz; i += 16) { vector<bool> packet = R[32 + i / 16]; for (int j = i; j < min(sz, i + 16); ++j) M.emplace_back(packet[pos[j - i]]); } return M; } #ifdef hwe signed main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); M.assign(31, 0), C.assign(31, 0), R.clear(); for (int i = 0; i < 31; ++i) { M[i] = random(2); } vector<int> index(31); iota(index.begin(), index.end(), 0); shuffle(index.begin(), index.end(), rng); for (int i = 0; i < 15; ++i) C[index[i]] = 1; for (auto x : M) cerr << x; cerr << '\n'; for (auto x : C) cerr << x; cerr << '\n'; // for (int i = 0; i < 31; ++i) { // int x; cin >> x; // M[i] = x; // } // for (int i = 0; i < 31; ++i) { // int x; cin >> x; // C[i] = x; // } send_message(M, C); cerr << "Packets used: " << R.size() << '\n'; vector<bool> ans = receive_message(R); for (auto x : ans) cerr << x << ' '; cerr << '\n'; if (ans == M) cerr << "Accepted\n"; else cerr << "Wrong Answer\n"; cerr << '\n'; return 0; } #endif

Compilation message (stderr)

message.cpp: In function 'void send_message(std::vector<bool>, std::vector<bool>)':
message.cpp:83:3: error: 'send_packet' was not declared in this scope
   83 |   send_packet(vector<bool>(31, C[i]));
      |   ^~~~~~~~~~~
message.cpp:97:2: error: 'send_packet' was not declared in this scope
   97 |  send_packet(packet);
      |  ^~~~~~~~~~~