# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
144714 | 2019-08-17T14:47:03 Z | socho | Data Transfer (IOI19_transfer) | C++14 | 13 ms | 2480 KB |
#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
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 6 ms | 1016 KB | secret mismatch |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 13 ms | 2480 KB | secret mismatch |
2 | Halted | 0 ms | 0 KB | - |