Submission #995293

#TimeUsernameProblemLanguageResultExecution timeMemory
995293biankData Transfer (IOI19_transfer)C++14
100 / 100
220 ms2764 KiB
#include "transfer.h" using namespace std; #define sz(x) int(x.size()) #define all(x) begin(x), end(x) vector<int> parity(vector<int> source) { int log = sz(source) == 63 ? 6 : 8; vector<int> par(log, 0); for (int i = 0; i < sz(source); i++) { for (int j = 0; j < log; j++) { if ((i + 1) >> j & 1) par[j] ^= source[i]; } } return par; } vector<int> get_attachment(vector<int> source) { vector<int> par = parity(source); int x = 0; for (int i = 0; i < sz(par); i++) { x ^= par[i]; } par.push_back(x); return par; } vector<int> retrieve(vector<int> data) { int cut = sz(data) == 70 ? 63 : 255; vector<int> source(begin(data), begin(data) + cut); vector<int> code(begin(data) + cut, end(data)); vector<int> par = parity(source); int x = 0; int p = 0; for (int i = 0; i < sz(code) - 1; i++) { if (code[i] != par[i]) x ^= 1 << i; p ^= code[i]; } if (code.back() != p) return source; if (x != 0) source[x - 1] ^= 1; return source; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...