제출 #1123769

#제출 시각아이디문제언어결과실행 시간메모리
1123769Mousa_Aboubaker메시지 (IOI24_message)C++20
43.96 / 100
694 ms860 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 < 31; i++) if(C[i] == 0) idx.push_back(i); for(int i = 0; i < 16; i++) { send_packet(vector<bool>(31, C[i])); } vector<bool> a(31, 0); a[idx[0]] = C[16]; send_packet(a); a.assign(31, 0); a[idx[0]] = C[17]; a[idx[1]] = C[18]; send_packet(a); a.assign(31, 0); a[idx[0]] = C[19]; a[idx[1]] = C[20]; a[idx[2]] = C[21]; a[idx[3]] = C[22]; send_packet(a); a.assign(31, 0); a[idx[0]] = C[23]; a[idx[1]] = C[24]; a[idx[2]] = C[25]; a[idx[3]] = C[26]; a[idx[4]] = C[27]; a[idx[5]] = C[28]; a[idx[6]] = C[29]; a[idx[7]] = C[30]; send_packet(a); int curr = 0; a.assign(31, 0); for(int i = 0; i < (int)M.size(); i++) { a[idx[i % 16]] = M[i]; if(i % 16 == 15) { send_packet(a); a.assign(31, 0); } } if((int)M.size() % 16 != 0) send_packet(a); a.assign(31, 0); int sz = (int)M.size(); for(int i = 0; i <= 10; i++) { a[idx[i]] = (sz >> i) & 1; } send_packet(a); } vector<bool> receive_message(vector<vector<bool>> R) { vector<bool> C(31, 1); for(int i = 0; i < 16; i++) { int cnt0 = count(R[i].begin(), R[i].end(), 0); if(cnt0 >= 16) C[i] = 0; } auto add = [&]() -> vector<int> { vector<int> idx; for(int i = 0; i < 31; i++) if(C[i] == 0) idx.push_back(i); return idx; }; vector<int> idx = add(); C[16] = R[16][idx[0]]; idx = add(); C[17] = R[17][idx[0]]; idx = add(); C[18] = R[17][idx[1]]; idx = add(); C[19] = R[18][idx[0]]; idx = add(); C[20] = R[18][idx[1]]; idx = add(); C[21] = R[18][idx[2]]; idx = add(); C[22] = R[18][idx[3]]; idx = add(); C[23] = R[19][idx[0]]; idx = add(); C[24] = R[19][idx[1]]; idx = add(); C[25] = R[19][idx[2]]; idx = add(); C[26] = R[19][idx[3]]; idx = add(); C[27] = R[19][idx[4]]; idx = add(); C[28] = R[19][idx[5]]; idx = add(); C[29] = R[19][idx[6]]; idx = add(); C[30] = R[19][idx[7]]; idx = add(); int sz = 0; for(int i = 0; i <= 10; i++) if(R.back()[idx[i]]) sz |= (1 << i); int curr = 0; vector<bool> M; for(int i = 20; i < (int)R.size(); i++) { for(auto j: idx) { M.push_back(R[i][j]); curr++; if(curr == sz) { i = 1e9; break; } } } return M; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...