# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
144714 | socho | Data Transfer (IOI19_transfer) | C++14 | 13 ms | 2480 KiB |
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 "transfer.h"
#include <bits/stdc++.h>
using namespace std;
vector<int> get_attachment(vector<int> source) {
int BLE;
int n = source.size();
if (n == 63) BLE = 6;
else BLE = 8;
int att[BLE];
memset(att, 0, sizeof att);
for (int i=0; i<BLE; i++) {
for (int j=0; j<n; j++) {
if (source[j] == 1) {
if ((1 << i) & j) {
att[i]++;
}
}
}
att[i] = att[i] % 2;
}
vector<int> fn;
int sm = 0;
for (int i=0; i<BLE; i++) {
fn.push_back(att[i]);
sm += att[i];
}
sm = sm % 2;
fn.push_back(sm);
return fn;
}
vector<int> retrieve(vector<int> data) {
int n;
int BLE;
if (data.size() == 70) {
n = 63;
BLE = 6;
}
else {
n = 255;
BLE = 8;
}
vector<int> rec;
for (int i=n; i<data.size(); i++) {
rec.push_back(data[i]);
}
int sm = 0;
for (int i=0; i<BLE; i++) {
sm += rec[i];
}
sm = sm % 2;
if (sm != data[data.size()-1]) {
vector<int> act;
for (int i=0; i<n; i++) {
act.push_back(data[i]);
}
return act;
}
int att[BLE];
memset(att, 0, sizeof att);
for (int i=0; i<BLE; i++) {
for (int j=0; j<n; j++) {
if (data[j] == 1) {
if ((1 << i) & j) {
att[i]++;
}
}
}
att[i] = att[i] % 2;
}
vector<int> act;
for (int i=0; i<n; i++) {
act.push_back(data[i]);
}
bool flag = false;
for (int i=0; i<BLE; i++) {
if (rec[i] != att[i]) {
flag = true;
}
}
if (!flag) return act;
int con = 0;
for (int i=0; i<BLE; i++) {
if (rec[i] != att[i]) {
con += (1 << i);
}
}
act[con] = 1 - act[con];
return act;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |