| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1364060 | eli | Data Transfer (IOI19_transfer) | C++20 | 101 ms | 1724 KiB |
#include "transfer.h"
#include <bits/stdc++.h>
using namespace std;
#define out(x) #x<<" = "<<x<<" "
std::vector<int> get_attachment(std::vector<int> source) {
vector<int> ans;
//ans = source;
int xorr = 0;
for(int i = 0; i < 8; i++){
xorr = 0;
//cout<<out(i)<<endl;
for(int j = 1; j <= source.size(); j++){
if((j & (1<<i)) != 0){
//cout<<out(j);
xorr = xorr ^ source[j - 1];
}
}
//cout<<endl;
ans.push_back(xorr);
}
xorr = 0;
/*for(int i = 0; i < ans.size(); i++){
xorr = xorr ^ ans[i];
}*/
for(int i = 0; i < source.size(); i++) xorr = xorr ^ source[i];
ans.push_back(xorr);
return ans;
}
vector<int> retrieve(vector<int> data) {
vector<int> ans;
ans.clear();
//cout<<data.size()<<endl;
int xorr = 0;
for(int i = 0; i < data.size() - 9; i++){
xorr = xorr ^ data[i];
}
if(xorr == data[data.size() - 1]){
for(int i = 0; i < data.size() - 9; i++) ans.push_back(data[i]);
//cout<<ans.size()<<" "<<data.size()<<endl;
return ans;
}
int curr = 0;
for(int i = 0; i < 8; i++){
xorr = 0;
for(int j = 1; j <= data.size() - 9; j++){
if((j & (1 <<i)) != 0) xorr = xorr ^ data[j - 1];
}
if(xorr != data[data.size() - 9 + i]){
curr += (1<<i);
//cout<<i<<" ";
}
}
curr--;
if(curr == -1){
for(int i = 0; i < data.size() - 9; i++) ans.push_back(data[i]);
//cout<<ans.size()<<" "<<data.size()<<endl;
return ans;
}
data[curr] = (data[curr] + 1) % 2;
/* bool ok = true;
for(int i = 0; i < 8; i++){
xorr = 0;
for(int j = 1; j <= data.size() - 9; j++){
if((j & (1 <<i)) != 0) xorr = xorr ^ data[j - 1];
}
if(xorr != data[data.size() - 9 + i]){
ok = false;
}
}
if(!ok) data[curr] = (data[curr] + 1) % 2;*/
for(int i = 0; i < data.size() - 9; i++){
ans.push_back(data[i]);
}
//cout<<ans.size()<<" "<<curr<<endl;
return ans;
}
Compilation message (stderr)
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
