| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1285907 | minhnguyent546 | Data Transfer (IOI19_transfer) | C++20 | 37 ms | 1732 KiB |
/**
* author minhnguyent546
* created_at Fri, 2025-10-31 21:24:00
**/
#include <vector>
#include <cassert>
#include "transfer.h"
std::vector<int> get_attachment(std::vector<int> source) {
int n = (int) source.size();
assert (n == 63 || n == 255);
int x = 0;
for (int i = 0; i < n; ++i) {
if (source[i] == 1) x ^= (i + 1);
}
// cerr << "x = " << x << '\n';
int sz;
if (n == 63) {
sz = 6;
} else {
sz = 8;
}
std::vector<int> b(sz + 1);
int cur = x;
int one = 0;
for (int i = 0; i < sz; ++i) {
if ((cur >> i) & 1) {
++one;
b[i] = 1;
}
}
b[sz] = (one & 1 ? 1 : 0);
return b;
}
std::vector<int> retrieve(std::vector<int> data) {
int sz = (int) data.size();
int k, n;
assert(sz == 70 || sz == 264);
if (sz == 70) {
n = 63;
k = 6;
} else {
n = 255;
k = 8;
}
int one = 0;
for (int i = n; i < sz; ++i) {
one += data[i];
}
if (one % 2 == 0) {
// corrupted in N bits
int x = 0;
for (int i = 0; i < k; ++i) {
if (data[i + n] == 1) {
x += (1 << i);
}
}
for (int i = 0; i < n; ++i) {
if (data[i] == 1) x ^= (i + 1);
}
// corrupted position is x;
// cerr << "x = " << x << '\n';
assert (x >= 0 && x <= n);
if (x > 0) {
data[x - 1] ^= 1;
}
} else {
// corrupted in K bits;
}
return std::vector<int>(data.begin(), data.begin() + n);
}
컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
