This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#include "transfer.h"
//#define int long long
#define pi pair<int, int>
#define pii pair<int, pi>
#define fi first
#define se second
#ifdef _WIN32
#define getchar_unlocked _getchar_nolock
#endif
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
std::vector<int> get_attachment(std::vector<int> source) {
int n = (int)source.size();
vector <int> ans;
for(int i = 0; (1 << i) < n; i++){
int x = 0;
for(int j = 0; j < n; j++)if(j >> i & 1)x ^= source[j];
ans.push_back(x);
}
int x = 0;
for(int i = 0; i < n; i++)x ^= source[i];
ans.push_back(x);
return ans;
}
std::vector<int> retrieve(std::vector<int> data) {
int n, num;
if((int)data.size() >= 200)n = 255, num = 9;
else n = 63, num = 7;
int tmp = 0;
for(int i = 0; i < n; i++)tmp ^= data[i];
if(tmp == data[(int)data.size() - 1]){
vector <int> ans;
for(int i = 0; i < n; i++)ans.push_back(data[i]);
return ans;
}
for(int i = 0; i < num; i++){
data[(int)data.size() - num + i] = !data[(int)data.size() - num + i];
bool f = 1;
for(int j = 0; (1 << j) < n; j++){
int a = 0;
for(int k = 0; k < n; k++)if(k >> j & 1)a ^= data[k];
if(a != data[(int)data.size() - num + j])f = 0;
}
int a = 0;
for(int j = 0; j < n; j++)a ^= data[j];
if(a != data[(int)data.size() - 1])f = 0;
if(f){
vector <int> ans;
for(int i = 0; i < n; i++)ans.push_back(data[i]);
return ans;
}
data[(int)data.size() - num + i] = !data[(int)data.size() - num + i];
}
int flipped = 0;
for(int i = 0; (1 << i) < n; i++){
int x = 0;
for(int j = 0; j < n; j++)if(j >> i & 1)x ^= data[j];
if(x != data[(int)data.size() - num + i])flipped ^= (1 << i);
}
data[flipped] = !data[flipped];
vector <int> ans;
for(int i = 0; i < n; i++)ans.push_back(data[i]);
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |