# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
679261 | That_Salamander | Data Transfer (IOI19_transfer) | C++14 | 246 ms | 2500 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<int> get_attachment(vector<int> source) {
vector<int> hamming;
int m = 1;
int x2 = 0;
while (m <= source.size()) {
int x = 0;
for (int i = 0; i < source.size(); i++) {
if (!(i & m)) {
x ^= source[i];
}
}
hamming.push_back(x);
x2 ^= x;
m <<= 1;
}
hamming.push_back(x2);
return hamming;
}
vector<int> retrieve(vector<int> data) {
int n = data.size() >= 255 ? 255 : 63;
int h = data.size() - n - 1;
vector<int> source(data.begin(), data.begin()+ n);
vector<int> hamming(h);
int x = 0;
for (int i = 0; i < h; i++) {
x ^= hamming[i] = data[n + i];
}
if (x != data[n + h]) return source;
vector<int> correct(h);
bool valid = true;
for (int i = 0; i < h; i++) {
int x = 0;
for (int j = 0; j < n; j++) {
if (!((j >> i) & 1)) {
x ^= source[j];
}
}
correct[i] = x == hamming[i];
if (!correct[i]) valid = false;
}
if (valid) return source;
int idx = 0;
for (int i = 0; i < h; i++) {
if (correct[i]) {
idx += 1 << i;
}
}
source[idx] ^= 1;
return source;
}
#ifdef LOCAL_TEST
#include <random>
vector<int> manipulate(vector<int>& data) {
vector<int> res = data;
if (rand() % 2) {
res[rand() % res.size()] ^= 1;
}
return res;
}
void doTest() {
int n = rand() % 2 ? 63 : 255;
vector<int> data(n);
for (int& x: data) {
x = rand() % 2;
}
vector<int> attached = data;
for (int x: get_attachment(data)) {
attached.push_back(x);
}
if (retrieve(manipulate(attached)) != data) {
cout << "Error!" << endl;
}
}
int main() {
for (int i = 0; i < 200000; i++) {
doTest();
}
cout << "Finished!" << endl;
}
#endif
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |