Submission #735873

#TimeUsernameProblemLanguageResultExecution timeMemory
735873rnl42Data Transfer (IOI19_transfer)C++14
100 / 100
266 ms2504 KiB
#include "transfer.h" using namespace std; #include <iostream> vector<int> get_attachment(vector<int> source) { const int N = source.size(); //assert(__builtin_popcount(N+1) == 1); const int K = __lg(N+1)+1; vector<int> attach(K); for (int i = 0; i < N; i++) { for (int b = 0; b < K-1; b++) { if (((i+1) >> b) & 1) { attach[b] ^= source[i]; } } attach.back() ^= source[i]; } return attach; } vector<int> retrieve(vector<int> data) { int N = data.size(); int K = __lg(N)+1; N -= K; vector<int> source(data.begin(), data.begin() + N); vector<int> newattach = get_attachment(source); int i = 0; for (int b = 0; b < K-1; b++) { if (newattach[b] != data[N+b]) { i |= (1<<b); } } i--; if (newattach.back() != data.back()) { if (i != -1) source[i] ^= 1; } return source; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...