이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "encoder.h"
#include "encoderlib.h"
# include <bits/stdc++.h>
using namespace std;
# define pb push_back
void encode(int N, int M[]) {
if (N <= 32) {
int id = 0;
for (int i = 0; i < N; i++) {
for (int j = 0; j < 8; j++) {
if ((1<<j)&M[i]) {
//cout<<"send "<<i<<" "<<j<<" "<<id<<"\n";
send(id);
}
id++;
}
}
} else {
vector <int> v;
for (int i = 0; i < N; i++) {
for (int j = 0; j < 8; j++) {
if ((1<<j)&M[i]) {
v.pb(1);
} else v.pb(0);
}
}
for (int i = 0; i < v.size(); i+=2) {
if (v[i] == 0 && v[i + 1] == 0) {
continue;
}
if (v[i] == 0 && v[i + 1] == 1) {
send(i / 2); continue;
}
if (v[i] == 1 && v[i + 1] == 0) {
send(i / 2); send(i / 2); continue;
}
if (v[i] == 1 && v[i + 1] == 1) {
send(i / 2); send(i / 2); send(i / 2); continue;
}
}
}
}
#include "decoder.h"
#include "decoderlib.h"
# include <bits/stdc++.h>
using namespace std;
# define pb push_back
const int MX = 1e4 + 5;
void decode(int N, int L, int X[]) {
vector <int> ans, x, cnt;
ans = vector <int>(MX, 0);
x = vector <int> (MX, 0);
cnt = vector <int> (MX, 0);
for (int i = 0; i < L; i++) x[i] = X[i];
//cout<<"received ";
//for (int i = 0; i < L; i++) cout<<x[i]<<" ";
//cout<<"\n";
if (N <= 32) {
for (int i = 0; i < L; i++) {
int id = x[i];
ans[id / 8] += (1<<(id % 8));
}
for (int i = 0; i < N; i++) {
output(ans[i]);
}
return ;
}
for (int i = 0; i < L; i++) {
cnt[x[i]]++;
}
vector <int> v;
for (int i = 0; i < 4 * N; i++) {
if (cnt[i] == 0) v.pb(0), v.pb(0);
else if (cnt[i] == 1) v.pb(0), v.pb(1);
else if (cnt[i] == 2) v.pb(1), v.pb(0);
else if (cnt[i] == 3) v.pb(1), v.pb(1);
}
int id = 0;
for (int i = 0; i < N; i++) {
for (int j = 0; j < 8; j++) {
if (v[id] == 1) ans[i] += (1<<j);
id++;
}
}
for (int i = 0; i < N; i++) {
output(ans[i]);
}
}
컴파일 시 표준 에러 (stderr) 메시지
encoder.cpp: In function 'void encode(int, int*)':
encoder.cpp:27:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
27 | for (int i = 0; i < v.size(); i+=2) {
| ~~^~~~~~~~~~
# | 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... |