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 <algorithm>
#include <iostream>
#include <vector>
#include <cstdint>
#include <cstdlib>
#include <cassert>
#include <queue>
#include <unordered_map>
#define PARROTS
#ifndef PARROTS_MAIN
#include "encoder.h"
#include "encoderlib.h"
#endif
template<typename T>
using Vec = std::vector<T>;
Vec<int> SplitInto4Bit(int N, int* message) {
Vec<int> ret;
for (int i = 0; i < N; ++i) {
ret.push_back(message[i]&15);
ret.push_back(message[i]>>4);
}
return ret;
}
void encode(int N, int* message_8) {
auto message = SplitInto4Bit(N, message_8);
for (int i = 0; i < message.size(); ++i) {
int index = (i&15);
send(message[i] | (index<<4));
if (i >= 16) {
send(message[i] | (index<<4));
}
}
}
#include <algorithm>
#include <iostream>
#include <vector>
#include <cstdint>
#include <cstdlib>
#include <cassert>
#include <queue>
#include <unordered_map>
#ifndef PARROTS_MAIN
#include "decoder.h"
#include "decoderlib.h"
#endif
#ifndef PARROTS
template<typename T>
using Vec = std::vector<T>;
#endif
void decode(int N, int L, int* X) {
Vec<int> decoded_4_bit(2*N);
std::unordered_map<int, int> Count;
for (int i = 0; i < L; ++i) {
++Count[X[i]];
}
for (int i = 0; i < L; ++i) {
int index = (X[i] >> 4);
int value = (X[i] & 15);
if (Count[X[i]] > 1) {
decoded_4_bit.at(index + 16) = value;
}
if (Count[X[i]] % 2 == 1) {
decoded_4_bit.at(index) = value;
}
}
for (int i = 0; i < 2*N; i += 2) {
int num = (decoded_4_bit[i] | (decoded_4_bit[i + 1]<<4));
output(num);
}
}
Compilation message (stderr)
encoder.cpp: In function 'void encode(int, int*)':
encoder.cpp:29:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i = 0; i < message.size(); ++i) {
~~^~~~~~~~~~~~~~~~
# | 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... |