This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#ifndef GRADER
#include "transfer.h"
#endif
#include "bits/stdc++.h"
using namespace std;
#define all(x) begin(x),end(x)
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }
template<typename T_container, typename T = typename enable_if<!is_same<T_container, string>::value, typename T_container::value_type>::type> ostream& operator<<(ostream &os, const T_container &v) { string sep; for (const T &x : v) os << sep << x, sep = " "; return os; }
#define debug(a) cerr << "(" << #a << ": " << a << ")\n";
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pi;
vi get_attachment(vi source) {
auto n = source.size();
vi output;
int last=0;
for(int i=0;(1<<i)<n;++i) {
output.push_back(0);
for(int j=0;j<n;++j) {
if((j&(1<<i))==0)
output.back()^=source[j];
}
last^=output.back();
}
output.push_back(last);
return output;
}
std::vector<int> retrieve(vi data) {
int k=__lg(data.size());
int n = (1<<k) -1;
vi extra(data.begin()+n,data.end());
data.erase(data.begin()+n,data.end());
int check=0;
for(int i: extra) check^=i;
if(check) return data;
extra.pop_back();
int wrong = 0;
for(int i=0;(1<<i) < n;++i) {
check=extra[i];
for(int j=0;j<n;++j) {
if((j&(1<<i))==0)
check^=data[j];
}
if(!check) wrong+=(1<<i);
}
if(wrong<data.size()) {
data[wrong]^=1;
}
return data;
}
Compilation message (stderr)
transfer.cpp: In function 'vi get_attachment(vi)':
transfer.cpp:18:20: warning: comparison of integer expressions of different signedness: 'int' and 'long unsigned int' [-Wsign-compare]
18 | for(int i=0;(1<<i)<n;++i) {
| ~~~~~~^~
transfer.cpp:20:16: warning: comparison of integer expressions of different signedness: 'int' and 'long unsigned int' [-Wsign-compare]
20 | for(int j=0;j<n;++j) {
| ~^~
transfer.cpp: In function 'std::vector<int> retrieve(vi)':
transfer.cpp:48:10: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
48 | if(wrong<data.size()) {
| ~~~~~^~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |