Submission #1123049

#TimeUsernameProblemLanguageResultExecution timeMemory
1123049Mousa_AboubakerMessage (IOI24_message)C++20
0 / 100
216 ms844 KiB
#include "message.h" #include <bits/stdc++.h> using namespace std; void send_message(vector<bool> M, vector<bool> C) { vector<int> idx; for(int i = 0; i < (int)C.size(); i++) if(C[i] == 0) idx.push_back(i); assert((int)idx.size() == 16); vector<int> idx2; for(int i = 0; i < 4; i++) { for(int j = 0; j < 4; j++) send_packet(vector<bool>(31, ((idx[i] >> j) & 1))); idx2.push_back(idx[i]); } assert((int)idx2.size() == 4); for(int i = 4; i < 8; i++) { vector<bool> b; for(int j = 0; j < 4; j++) b.push_back((idx[i] >> j) & 1); vector<bool> a(31, 0); for(int j = 0; j < 4; j++) a[idx2[j]] = b[j]; idx2.push_back(idx[i]); send_packet(a); } assert((int)idx2.size() == 8); for(int i = 8; i < 16; i += 2) { vector<bool> b, c; for(int j = 0; j < 4; j++) { b.push_back((idx[i] >> j) & 1); c.push_back((idx[i + 1] >> j) & 1); } vector<bool> a(31, 0); for(int j = 0; j < 4; j++) { a[idx2[j]] = b[j]; a[idx2[j + 4]] = c[j]; } idx2.push_back(idx[i]); idx2.push_back(idx[i + 1]); send_packet(a); } assert((int)idx2.size() == 16); { int sz = (int)M.size(); vector<bool> b; for(int j = 0; j < 10; j++) b.push_back((sz >> j) & 1); vector<bool> a(31, 0); for(int j = 0; j < 10; j++) a[idx2[j]] = b[j]; send_packet(a); } int curr = 0; vector<bool> a(31, 0); for(int i = 0; i < (int)M.size(); i++) { a[idx[curr++]] = M[i]; if(curr == 16) { send_packet(a); a.assign(31, 0); curr = 0; } } if(curr) send_packet(a); } vector<bool> receive_message(vector<vector<bool>> R) { vector<bool> M(31, 1); int n = (int)R.size(); vector<int> b; for(int i = 0; i < 4; i++) { int idx = 0; for(int j = 0; j < 4; j++) { int k = i * 4 + j; int cnt0 = 0; for(auto l: R[k]) cnt0 += !l; if(cnt0 < 16) idx |= (1 << j); } M[idx] = 0; b.push_back(idx); } for(int i = 16; i < 20; i++) { int idx = 0; for(int j = 0; j < 4; j++) { if(R[i][b[j]] == 1) idx |= (1 << j); } M[idx] = 0; b.push_back(idx); } for(int i = 20; i < 24; i++) { int idx1 = 0, idx2 = 0; for(int j = 0; j < 4; j++) { if(R[i][b[j]] == 1) idx1 |= (1 << j); if(R[i][b[j + 4]] == 1) idx2 |= (1 << j); } M[idx1] = M[idx2] = 0; b.push_back(idx1); b.push_back(idx2); } int sz = 0; for(int i = 0; i < 10; i++) if(R[24][b[i]] == 1) sz |= (1 << i); vector<bool> res; int x = 0; for(int i = 25; i < n; i++) { for(int j = 0; j < 16; j++) { if(R[i][b[j]] == 0) res.push_back(0); else res.push_back(1); x++; if(x == sz) break; } } return res; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...