이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "encoder.h"
#include "encoderlib.h"
#include <bits/stdc++.h>
using namespace std;
void encode(int N, int M[]){
if (N <= 32) {
for (int i = 0; i < N; i++) {
int a = M[i] >> 4;
int b = M[i] & (0xf);
send(((i * 2) << 2) + (a >> 2));
send(((i * 2) << 2) + (a >> 2));
send(((i * 2) << 2) + (a & 3));
send(((i * 2 + 1) << 2) + (b >> 2));
send(((i * 2 + 1) << 2) + (b >> 2));
send(((i * 2 + 1) << 2) + (b & 3));
}
}
else {
int cnt = 0;
int temp[64];
memcpy(temp, M, sizeof(temp));
for (int i = 0; i < N; i++) {
for (int j = 0; j < 4; j++) {
int now = M[i] & 3;
cnt += now;
M[i] /= 4;
}
}
memcpy(M, temp, sizeof(temp));
if (cnt > N * 6) {
for (int i = 0; i < N; i++) {
for (int j = 0; j < 4; j++) {
int now = M[i] & 3;
now = 3 - now;
while (now--)
send((i << 2) + j);
M[i] /= 4;
}
}
send(0);
send(0);
send(0);
send(0);
}
else {
for (int i = 0; i < N; i++) {
for (int j = 0; j < 4; j++) {
int now = M[i] & 3;
while (now--)
send((i << 2) + j);
M[i] /= 4;
}
}
}
}
}
#include "decoder.h"
#include "decoderlib.h"
void decode(int N, int L, int X[]){
if (N <= 32) {
int ans[32] = { 0, }, cnt[64][4] = { 0, };
for (int i = 0; i < L; i++)
cnt[X[i] >> 2][X[i] & 3]++;
for (int i = 0; i < 64; i++) {
for (int j = 0; j < 4; j++) {
if (cnt[i][j] == 1) {
ans[i / 2] |= i & 1 ? j : j << 4;
}
else if (cnt[i][j] == 2) {
ans[i / 2] |= i & 1 ? j << 2 : j << 6;
}
else if (cnt[i][j] == 3) {
ans[i / 2] |= i & 1 ? (j * 4 + j) : (j * 4 + j) << 4;
}
}
}
for (int i = 0; i < N; i++) {
output(ans[i]);
}
}
else {
int ans[64] = { 0, }, cnt[64][4] = { 0, };
for (int i = 0; i < L; i++)
cnt[X[i] >> 2][X[i] & 3]++;
if(cnt[0][0]>=4){
cnt[0][0] -= 4;
for (int i = 0; i < 64; i++) {
for (int j = 0; j < 4; j++) {
ans[i] |= ((3 - cnt[i][j]) << (j * 2));
}
}
}
else {
for (int i = 0; i < 64; i++) {
for (int j = 0; j < 4; j++) {
ans[i] |= (cnt[i][j] << (j * 2));
}
}
}
for (int i = 0; i < N; i++) {
output(ans[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... |