| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1310836 | nikoloz-ch | Data Transfer (IOI19_transfer) | C++20 | 8 ms | 3252 KiB |
#include <bits/stdc++.h>
#include "transfer.h"
using namespace std;
vector<int> get_attachment(vector<int> source){
int p = 0, k = 0;
const int n = source.size();
const int kp = (n == 63 ? 6 : 8);
for(int i = 0; i < n; ++i) if(source[i]) p ^= (i + 1);
for(int b = 0; b < kp; ++b){
int bit = (p >> b) & 1;
source.push_back(bit);
k += bit;
}
source.push_back(k % 2);
return source;
}
vector<int> retrieve(vector<int> data){
int p = 0, k = 0, kp = 0;
const int n = data.size();
int knt = ((n - 7) == 63 ? 6 : 8);
int pos = n - (knt + 1);
for(int i = 0; i < pos; i++) if(data[i]) p ^= (i + 1);
for(int b = 0; b < knt; b++){
int idx = pos + b;
if(idx < 0 || idx >= n-1) return {};
if(data[idx]){
k |= (1 << b);
++kp;
}
}
vector<int> ans;
if(data.back() != (kp % 2)){
for(int i = 0; i < pos; ++i) ans.push_back(data[i]);
return ans;
}
int cnt = p ^ k;
for(int i = 0; i < pos; ++i){
if(cnt != 0 && i == (cnt - 1)) ans.push_back(data[i] ? 0 : 1);
else ans.push_back(data[i]);
}
return ans;
}
Compilation message (stderr)
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
