이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "encoder.h"
#include "encoderlib.h"
#include <iostream>
#include <vector>
using namespace std;
void encode(int N, int M[])
{
vector <int> v1, v2 = {255, 255, 255, 255};
for (int i = 0; i < N; i++)
for (int j = 0; j < 4; j++)
{
bool bit1 = M[i] & (1 << (2 * j));
bool bit2 = M[i] & (1 << (2 * j + 1));
int val = bit1 + 2 * bit2;
int pos = 4 * i + j;
for (int k = 0; k < val; k++)
v1.push_back(pos);
for (int k = 0; k < 3 - val; k++)
v2.push_back(pos);
}
if (v1.size() < v2.size())
for (auto it : v1)
send(it);
else
for (auto it : v2)
send(it);
}
#include "decoder.h"
#include "decoderlib.h"
#include <iostream>
#include <vector>
using namespace std;
void decode(int N, int L, int X[])
{
vector <int> freq(260, 0);
for (int i = 0; i < L; i++)
freq[X[i]]++;
int ok;
if (freq[255] < 4)
ok = 0;
else
{
ok = 1;
freq[255] = freq[255] - 4;
}
for (int i = 0; i < N; i++)
{
int val = 0;
for (int j = 0; j < 4; j++)
{
int aux = freq[4 * i + j];
if (aux == 1)
val = val | (1 << (2 * j));
else
if (aux == 2)
val = val | (1 << (2 * j + 1));
else
if (aux == 3)
{
val = val | (1 << (2 * j));
val = val | (1 << (2 * j + 1));
}
}
if (ok == 1)
val = (~val) & 255;
output(val);
}
}
# | 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... |