Submission #210775

#TimeUsernameProblemLanguageResultExecution timeMemory
210775Alexa2001Data Transfer (IOI19_transfer)C++17
100 / 100
228 ms2928 KiB
#include "transfer.h" #include <bits/stdc++.h> using namespace std; vector<int> get_attachment(vector<int> source) { vector<int> a; int n; if(source.size() < 64) n = 6; else n = 8; int xor_bits = 0; int i, j; for(i=0; i<n; ++i) { int bit = 0; for(j=0; j<source.size(); ++j) if(!(j & (1<<i))) bit ^= source[j]; a.push_back(bit); xor_bits ^= bit; } a.push_back(xor_bits); return a; } vector<int> retrieve(vector<int> data) { int n; if(data.size() < 64 + 7) n = 6; else n = 8; int xor_bits = 0, m = data.size() - n - 1; vector<int> b(n), ans; int i, j; for(i=0; i<n; ++i) { int bit = 0; for(j=0; j<m; ++j) if(!(j & (1<<i))) bit ^= data[j]; b[i] = bit; } int bad = 0; for(i=0; i<n; ++i) { if(b[i] != data[m + i]) bad |= (1<<i); xor_bits ^= data[m + i]; } ans = data; ans.resize(m); if(bad && xor_bits == data.back()) ans[bad ^ ((1<<n) - 1)] ^= 1; return ans; }

Compilation message (stderr)

transfer.cpp: In function 'std::vector<int> get_attachment(std::vector<int>)':
transfer.cpp:19:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(j=0; j<source.size(); ++j)
                  ~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...