Submission #735867

#TimeUsernameProblemLanguageResultExecution timeMemory
735867rnl42Data Transfer (IOI19_transfer)C++14
60 / 100
7 ms2996 KiB
#include "transfer.h" using namespace std; 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; } else { if (i != -1) source[N+__lg(i+1)] ^= 1; } return source; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...