| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1363650 | timmytimtam | Data Transfer (IOI19_transfer) | C++20 | 2 ms | 1724 KiB |
#include "transfer.h"
std::vector<int> get_attachment(std::vector<int> source) {
int xortotal = 0;
for(int i = 0;i < source.size();i++){
if(source[i]) xortotal ^= (i+1);
}
if(source.size() == 63){
std::vector<int> attachment(7);
int parity = 0;
for(int i = 0;i < 6;i++){
if((xortotal >> i) & 1){
attachment[i] = 1;
parity = !parity;
}
}
attachment[6] = parity;
return attachment;
}else{
std::vector<int> attachment(9);
int parity = 0;
for(int i = 0;i < 8;i++){
if((xortotal >> i) & 1){
attachment[i] = 1;
parity = !parity;
}
}
attachment[8] = parity;
return attachment;
}
}
std::vector<int> retrieve(std::vector<int> data) {
std::vector<int> source,attachment;
int parity = data[data.size() - 1];
if(data.size() == 70){
for(int i = 0;i < 63;i++){
source.push_back(data[i]);
}
for(int i = 63;i < data.size()-1;i++){
attachment.push_back(data[i]);
}
}else{
for(int i = 0;i < 255;i++){
source.push_back(data[i]);
}
for(int i = 255;i < data.size()-1;i++){
attachment.push_back(data[i]);
}
}
int xortotal = 0,rexortotal = 0, reparity = 0;
for(int i = 0;i < source.size();i++){
if(source[i]) xortotal ^= (i+1);
}
for(int i = 0;i < attachment.size();i++){
if(attachment[i]){
rexortotal += (1<<i);
reparity = !reparity;
}
}
if(xortotal != rexortotal && parity != reparity){
source[(xortotal ^ rexortotal) - 1] = !source[(xortotal ^ rexortotal) - 1];
}
return source;
}
Compilation message (stderr)
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
