이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "encoder.h"
#include "encoderlib.h"
#ifndef MINC
#define MINC
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pb emplace_back
#define AI(i) begin(i), end(i)
template<class T> bool chmin(T &a, T b) { return b < a ? (a = b, true) : false; }
template<class T> bool chmax(T &a, T b) { return a < b ? (a = b, true) : false; }
#ifdef KEV
#define DE(args...) kout("[ " + string(#args) + " ] = ", args)
void kout() { cerr << endl; }
template<class T, class ...U> void kout(T a, U ...b) { cerr << a << ' ', kout(b...); }
template<class T> void debug(T L, T R) { while (L != R) cerr << *L << " \n"[next(L) == R], ++L; }
#else
#define DE(...) 0
#define debug(...) 0
#endif
#endif
// send(int b)
void encode(int N, int M[]) {
static const int MAX_N = 256, F = 14;
static int cnt[MAX_N], sd[MAX_N];
for (int i = 0;i < N;++i)
++cnt[M[i]];
for (int i = 0;i < MAX_N;++i)
sd[i] = 4 * cnt[i];
for (int i = 1;i < MAX_N;++i) cnt[i] += cnt[i-1];
int b = 0;
for (int i = 0;i < N;++i) {
int V = --cnt[ M[i] ];
if (i < F)
for (int j = 0;j < 6;++j)
sd[b++] += (V >> j & 1);
else
for (int j = 0;j < 6;j += 2)
sd[b++] += (V >> j & 0b11);
}
for (int i = 0;i < MAX_N;++i)
for (int j = 0;j < sd[i];++j) send(i);
memset(cnt, 0, sizeof(cnt));
memset(sd, 0, sizeof(sd));
}
#include "decoder.h"
#include "decoderlib.h"
#ifndef MINC
#define MINC
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pb emplace_back
#define AI(i) begin(i), end(i)
template<class T> bool chmin(T &a, T b) { return b < a ? (a = b, true) : false; }
template<class T> bool chmax(T &a, T b) { return a < b ? (a = b, true) : false; }
#ifdef KEV
#define DE(args...) kout("[ " + string(#args) + " ] = ", args)
void kout() { cerr << endl; }
template<class T, class ...U> void kout(T a, U ...b) { cerr << a << ' ', kout(b...); }
template<class T> void debug(T L, T R) { while (L != R) cerr << *L << " \n"[next(L) == R], ++L; }
#else
#define DE(...) 0
#define debug(...) 0
#endif
#endif
// output(int b)
void decode(int N, int L, int X[]) {
static const int MAX_N = 256, F = 14;
static int cnt[MAX_N];
vector<int> val;
for (int i = 0;i < L;++i)
++cnt[X[i]];
for (int i = 0;i < MAX_N;++i) {
while (cnt[i] >= 4)
cnt[i] -= 4, val.pb(i);
}
assert(val.size() == N);
int b = 0;
for (int i = 0;i < N;++i) {
int res = 0;
if (i < F)
for (int j = 0;j < 6;++j)
res += cnt[b++] << j;
else
for (int j = 0;j < 6;j += 2)
res += cnt[b++] << j;
output(val[res]);
}
memset(cnt, 0, sizeof(cnt));
}
컴파일 시 표준 에러 (stderr) 메시지
In file included from /usr/include/c++/9/cassert:44,
from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:33,
from decoder.cpp:7:
decoder.cpp: In function 'void decode(int, int, int*)':
decoder.cpp:40:20: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
40 | assert(val.size() == N);
| ~~~~~~~~~~~^~~~
# | 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... |