Submission #1111094

#TimeUsernameProblemLanguageResultExecution timeMemory
1111094thieunguyenhuyMessage (IOI24_message)C++17
0 / 100
62 ms420 KiB
#ifndef hwe #include "message.h" #endif #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)) 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) { // vector<int> pos; pos.reserve(16); // for (int i = 0; i < 31; ++i) if (!C[i]) { // pos.emplace_back(i); // } // assert(pos.size() == 16); // int bitM = 0; // auto nextBit = [&]() { // if (bitM < M.size()) return bool(M[bitM++]); // return !M.back(); // }; vector<vector<bool>> packets(1, vector<bool>(31, 0)); // for (int i = 0; i < 16; ++i) { // int d = (pos[(i + 1) % 16] - pos[i] + 31) % 31; // packets[d - 1][pos[i]] = 1; // for (int j = d; j < 66; ++j) { // packets[j][pos[i]] = nextBit(); // } // } // cerr << "mkq\n"; for (auto packet : packets) send_packet(packet); } vector<bool> receive_message(vector<vector<bool>> R) { vector<int> nxt(31, -1); for (int i = 0; i < 66; ++i) { vector<bool> packet = R[i]; for (int j = 0; j < 31; ++j) if (packet[j] && nxt[j] == -1) { nxt[j] = (j + i + 1) % 31; } } vector<int> pos; pos.reserve(16); for (int i = 0; i < 31; ++i) { vector<bool> vis(31, false); int u = i, cycleSize = 0; while (!vis[u]) { vis[u] = true, ++cycleSize; u = nxt[u]; } if (cycleSize == 16) { for (int j = 0, u = i; j < 16; ++j, u = nxt[u]) { pos.emplace_back(u); } break; } } sort (pos.begin(), pos.end()); vector<bool> M; for (int i = 0; i < 16; ++i) { int d = (pos[(i + 1) % 16] - pos[i] + 31) % 31; for (int j = d; j < 66; ++j) M.emplace_back(R[j][pos[i]]); } int last = M.back(); while (M.back() == last) M.pop_back(); return M; } #ifdef hwe void solve(bool isLocal = false) { // M.assign(1024, 0), C.assign(31, 0), R.clear(); // for (int i = 0; i < M.size(); ++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; // if (isLocal) { // cerr << "M = "; // for (auto x : M) cerr << x; // cerr << '\n'; // cerr << "C = "; // for (auto x : C) cerr << x; // cerr << '\n'; // } // send_message(M, C); // vector<bool> ans = receive_message(R); // if (isLocal) { // cerr << "Ans: "; // for (auto x : ans) cerr << x; // cerr << '\n'; // if (ans == M) cerr << "Accepted\n"; // else { // cerr << "Wrong Answer\n"; // exit(0); // } // } } signed main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); for (int _ = 0; _ < 10; ++_) { solve(true); } cerr << '\n'; return 0; } #endif
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...