이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "encoder.h"
#include "encoderlib.h"
#include <vector>
using namespace std;
void encode(int N, int M[]) {
int i, j, t;
vector<int> c0, c1;
for(i=0; i<N; i++) {
t = M[i];
for(j=0; j<(t>>6&3); j++) c0.push_back(i*4);
for(j=0; j<(t>>4&3); j++) c0.push_back(i*4+1);
for(j=0; j<(t>>2&3); j++) c0.push_back(i*4+2);
for(j=0; j<(t>>0&3); j++) c0.push_back(i*4+3);
for(j=0; j<3-(t>>6&3); j++) c1.push_back(i*4);
for(j=0; j<3-(t>>4&3); j++) c1.push_back(i*4+1);
for(j=0; j<3-(t>>2&3); j++) c1.push_back(i*4+2);
for(j=0; j<3-(t>>0&3); j++) c1.push_back(i*4+3);
}
if(c0.size() < c1.size()) {
for(i=0; i<c0.size(); i++) send(c0[i]);
} else {
for(i=0; i<c1.size(); i++) send(c1[i]);
for(i=0; i<4; i++) send(0);
}
}
#include "decoder.h"
#include "decoderlib.h"
void decode(int N, int L, int X[]) {
int i, c[260]={};
for(i=0; i<L; i++) c[X[i]]++;
if(c[0]<4) {
for(i=0; i<N; i++) {
output(c[i*4]*64 + c[i*4+1]*16 + c[i*4+2]*4 + c[i*4+3]);
}
} else {
c[0] -= 4;
for(i=0; i<N; i++) {
output((3-c[i*4])*64 + (3-c[i*4+1])*16 + (3-c[i*4+2])*4 + (3-c[i*4+3]));
}
}
}
컴파일 시 표준 에러 (stderr) 메시지
encoder.cpp: In function 'void encode(int, int*)':
encoder.cpp:21:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
21 | for(i=0; i<c0.size(); i++) send(c0[i]);
| ~^~~~~~~~~~
encoder.cpp:23:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
23 | for(i=0; i<c1.size(); i++) send(c1[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... |