Submission #1210050

#TimeUsernameProblemLanguageResultExecution timeMemory
1210050trimkus메시지 (IOI24_message)C++20
0 / 100
0 ms740 KiB
#include "message.h" #include <bits/stdc++.h> using namespace std; const int LIMIT = 66; void send_message(std::vector<bool> M, std::vector<bool> C) { std::vector<bool> A(31, 0); int N = (int)M.size(); vector<int> dist(31, -1); for (int i = 0; i < 31; ++i) { if (C[i] == 0) { int d = 1; for (int j = (i + 1) % 31; C[j] == 1; j = (j + 1) % 31) { d++; } dist[i] = d - 1; } } // cout << "DIST:" << endl; // for (int i = 0; i < 31; ++i) { // cout << dist[i] << " "; // } // cout << endl; vector<bool> send[31]; int ptr = (int)M.size() - 1025; for (int i = 0; i < 31; ++i) { // cout << "BEFORE = " << ptr; if (C[i] == 0) { while (dist[i] > 0) { send[i].push_back(1); dist[i]--; } send[i].push_back(0); } else { while ((int)send[i].size() < LIMIT) { // assert(C[i] != 0); send[i].insert(send[i].begin(), 0); } } // cout << "AFTER = " << ptr << "\n"; } for (int i = 0; i < 31; ++i) { if (C[i] == 0) { while (ptr < -1 && (int)send[i].size() < LIMIT) { send[i].push_back(0); ptr++; } while ((int)send[i].size() < LIMIT && ptr == -1) { send[i].push_back(1); ptr++; cerr << "STARTING AT " << i << " " << send[i].size() - 1 << "\n"; } while (ptr < N && (int)send[i].size() < LIMIT) { send[i].push_back(M[ptr++]); cout << "NOW AT " << i << " " << send[i].size() - 1 << "\n"; } } } cout << "PTR = " << ptr << ", wanted = " << N << "\n"; // for (int i = 0; i < 31; ++i) { // if (C[i] == 0 || C[i] == 1) { // cout << setw(4) << left << i << " = "; // for (auto u : send[i]) { // cout << u << " "; // } // cout << endl; // } // } // cout << "HERE!" << endl; for (int i = 0; i < 31; ++i) { // cout << i << endl; // assert((int)send[i].size() == LIMIT); // cout << i << endl; } for (int i = 0; i < LIMIT; ++i) { for (int j = 0; j < 31; ++j) { A[j] = send[j][i]; } send_packet(A); } // cout << "DONE SENDING..." << endl; } std::vector<bool> receive_message(std::vector<std::vector<bool>> R) { vector<bool> res; vector<int> nxt(31, -1); vector<bool> C[31]; int N = (int)R.size(); for (int i = 0; i < N; ++i) { for (int j = 0; j < 31; ++j) { // cout << R[i][j] << " "; C[j].push_back(R[i][j]); } // cout << endl; } // cout << endl; for (int i = 0; i < 31; ++i) { auto& v = C[i]; // for (auto u : v) { // cout << u << " "; // } // cout << endl; if (v[0] == 0) { nxt[i] = (i + 1) % 31; v.erase(v.begin()); } else { int dist = 0; while (v.size() && v[0] == 1) { dist++; v.erase(v.begin()); } // cout << i << " = " << dist << "\n"; dist++; nxt[i] = (i + dist) % 31; v.erase(v.begin()); } } int start = -1; for (int i = 0; i < 31; ++i) { cout << nxt[i] << " "; } cout << endl; for (int i = 0; start == -1 && i < 31; ++i) { if (nxt[i] == -1) continue; int j = i; int d = 0; while (d < 16 && j >= i) { d++; j = nxt[j]; if (j == i) break; } if (d == 16 && j == i) { start = i; } // cout << i << " -> " << j << endl; } // assert(start != -1); bool good[31]; for (int i = 0; i < 31; ++i) good[i] = false; { int ni = start; good[ni] = true; ni = nxt[ni]; while (ni != start) { good[ni] = true; ni = nxt[ni]; } } for (int i = 0; i < 31; ++i) { cout << good[i] << " "; } cout << endl; bool can = false; for (int i = 0; i < 31; ++i) { if (good[i]) { auto& v = C[i]; int j = (nxt[i] - i + 31) % 31; // for (auto u : v) { // cout << u << " "; // } // cout << "\n"; for (auto u : v) { j++; if (!can && u == 1) { can = true; cout << "STARTING AT " << i << " " << j - 1 << "\n"; continue; } if (can) { res.push_back(u); cout << "NOW AT " << i << " " << j - 1 << "\n"; } } } } return res; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...