Submission #973176

#TimeUsernameProblemLanguageResultExecution timeMemory
973176sleepntsheepData Transfer (IOI19_transfer)C++17
100 / 100
46 ms2764 KiB
#include "transfer.h" std::vector<int> get_attachment(std::vector<int> source) { int A; if (source.size() == 63) A = 6; else A = 8; int xorsum = 0; std::vector<int> v; for (int i = 0; i < (int)source.size(); ++i) if (source[i]) xorsum ^= i + 1; for (int i = 0; i < A; ++i) v.push_back((xorsum>>i)&1); v.push_back(__builtin_parity(xorsum)); return v; } std::vector<int> retrieve(std::vector<int> data) { int A; if (data.size() < 100) A = 6; else A = 8; int xorsum = 0; int n = (int)data.size() - A - 1; for (int i = 0; i < n; ++i) if (data[i]) xorsum ^= i + 1; int xordat = 0, dat_par = data.back(); for (int i = n; i < n + A; ++i) xordat ^= (data[i]<<(i-n)); while ((int)data.size() > n) data.pop_back(); if (__builtin_parity(xordat) != dat_par) return data; int i = xorsum ^ xordat; if(i) data[i-1] ^= 1; return data; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...