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 "encoder.h"
#include "encoderlib.h"
#include <bits/stdc++.h>
using namespace std;
void encode(int n, int _a[]) {
vector<int> a(_a, _a + n);
for (int b = 0; b < 8; b++) {
int cur = 0;
for (int i = 0; i < n; i++) {
if ((a[i] >> b & 1) != cur) {
cur ^= 1;
if (b < 4) {
send(b + 4 * i);
} else {
send(b - 4 + 4 * i);
send(b - 4 + 4 * i);
}
}
}
}
}
#include "decoder.h"
#include "decoderlib.h"
#include <bits/stdc++.h>
using namespace std;
void decode(int n, int k, int _a[]) {
vector<int> a(_a, _a + k);
vector<int> freq(256, 0);
for (int x : a) {
freq[x]++;
}
vector<vector<int>> change(8, vector<int>(n, 0));
for (int x = 0; x < 256; x++) {
if (freq[x] & 1) {
change[x % 4][x / 4] = 1;
}
if (freq[x] >> 1 & 1) {
change[x % 4 + 4][x / 4] = 1;
}
}
vector<int> res(n, 0);
for (int b = 0; b < 8; b++) {
int cur = 0;
for (int i = 0; i < n; i++) {
cur ^= change[b][i];
res[i] += cur << b;
}
}
for (int x : res) {
output(x);
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |