Submission #156504

#TimeUsernameProblemLanguageResultExecution timeMemory
156504WLZData Transfer (IOI19_transfer)C++17
100 / 100
392 ms2844 KiB
#include "transfer.h" #include <bits/stdc++.h> using namespace std; vector<int> get_attachment(vector<int> source) { int n = (int) source.size(); vector<int> ans; for (int i = 0; (1 << i) < n; i++) { ans.push_back(0); for (int j = 1; j <= n; j++) { if (j & (1 << i)) { ans.back() = (ans.back() + source[j - 1]) % 2; } } } ans.push_back(accumulate(ans.begin(), ans.end(), 0) % 2); return move(ans); } vector<int> retrieve(vector<int> data) { int n = ((int) data.size() == 70 ? 63 : 255); int x = 0; for (int i = n; i < (int) data.size() - 1; i++) { x = (x + data[i]) % 2; } if (x == data.back()) { vector<int> tmp; for (int i = 0; (1 << i) < n; i++) { tmp.push_back(0); for (int j = 1; j <= n; j++) { if (j & (1 << i)) { tmp.back() = (tmp.back() + data[j - 1]) % 2; } } } int k = 0; for (int i = 0; (1 << i) < n; i++) { if (tmp[i] != data[n + i]) { k += (1 << i); } } if (k > 0) { data[k - 1] = !data[k - 1]; } } return vector<int>(data.begin(), data.begin() + n); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...