제출 #1123863

#제출 시각아이디문제언어결과실행 시간메모리
1123863math_rabbit_1028메시지 (IOI24_message)C++20
10 / 100
593 ms804 KiB
#include "message.h" using namespace std; void send_message(vector<bool> M, vector<bool> C) { bool t = !(M.back()); while (M.size() < 1025) M.push_back(t); reverse(M.begin(), M.end()); int texts[67][31]; for (int i = 1; i <= 66; i++) { for (int j = 0; j < 31; j++) { texts[i][j] = -1; } } for (int j = 0; j < 31; j++) { if (C[j]) continue; int t = 1; while (true) { if (!C[(j+t)%31]) break; t++; } for (int i = 1; i < t; i++) texts[i][j] = 0; texts[t][j] = 1; } for (int i = 1; i <= 66; i++) { for (int j = 0; j < 31; j++) { if (texts[i][j] >= 0) continue; if (C[j]) texts[i][j] = 0; else { texts[i][j] = M.back(); M.pop_back(); } } } for (int i = 1; i <= 66; i++) { vector<bool> A(31, 0); for (int j = 0; j < 31; j++) { A[j] = texts[i][j]; } send_packet(A); } } vector<bool> receive_message(vector<vector<bool>> R) { vector<int> nxt(31, 0); for (int j = 0; j < 31; j++) { int t = 0; while (t < 66 && R[t][j] == 0) t++; nxt[j] = (j+t+1)%31; } vector<int> idx; for (int i = 0; i < 31; i++) { int t = 16, v = i; idx.clear(); while (t--) { v = nxt[v]; idx.push_back(v); } if (i == idx.back()) break; } vector<bool> C(31, 1); for (int x : idx) C[x] = 0; int texts[67][31]; for (int i = 1; i <= 66; i++) { for (int j = 0; j < 31; j++) { texts[i][j] = 0; } } for (int j = 0; j < 31; j++) { if (C[j]) continue; int t = 1; while (true) { if (!C[(j+t)%31]) break; t++; } for (int i = 1; i <= t; i++) texts[i][j] = -1; } vector<bool> ret; for (int i = 0; i < 66; i++) { for (int j = 0; j < 31; j++) { if (texts[i+1][j] == -1) continue; if (C[j]) continue; ret.push_back(R[i][j]); } } while (true) { int m = ret.size()-1; if (ret[m] != ret[m-1]) break; ret.pop_back(); } ret.pop_back(); return ret; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...