이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "encoder.h"
#include "encoderlib.h"
#include<bits/stdc++.h>
using namespace std;
void encode(int N, int M[]) {
int c = 0, t;
vector< int > v[5];
int P[500] = {0};
int cc[500] = {0};
for(int i=0; i<N; i++) {
int tt = M[i];
for(int j = 0; j < 8; j+=2) {
P[c] = tt % 4;
cc[P[c]]++;
v[P[c]].push_back(c);
tt /= 4;
c++;
}
}
int mx = max(max(cc[0], cc[1]), max(cc[2], cc[3]));
if(mx == cc[0]) { t = 0; send(0); send(0); send(0); send(0); send(0); send(0);}
else if(mx == cc[1]) { t = 1; send(1); send(1); send(1); send(1); send(1); send(1);}
else if(mx == cc[2]) { t = 2; send(2); send(2); send(2); send(2); send(2); send(2);}
else if(mx == cc[3]) { t = 3; send(3); send(3); send(3); send(3); send(3); send(3);}
int s = 1;
if(t != 0) {
for(int i = 0; i < v[0].size(); i++) {
int tt = s;
while(tt--) send(v[0][i]);
} s++;
}
if(t != 1) {
for(int i = 0; i < v[1].size(); i++) {
int tt = s;
while(tt--) send(v[1][i]);
} s++;
}
if(t != 2) {
for(int i = 0; i < v[2].size(); i++) {
int tt = s;
while(tt--) send(v[2][i]);
} s++;
}
if(t != 3) {
for(int i = 0; i < v[3].size(); i++) {
int tt = s;
while(tt--) send(v[3][i]);
} s++;
}
}
#include "decoder.h"
#include "decoderlib.h"
#include<bits/stdc++.h>
using namespace std;
void decode(int N, int L, int X[]) {
int cc[500] = {0}, t = 0;
for(int i=0; i<L; i++) {
cc[X[i]]++;
}
if(cc[0] > 5) { cc[0] -= 6; t = 0;}
if(cc[1] > 5) { cc[1] -= 6; t = 1;}
if(cc[2] > 5) { cc[2] -= 6; t = 2;}
if(cc[3] > 5) { cc[3] -= 6; t = 3;}
for(int i = 0; i < N * 4; i++) {
if(cc[i] == 0) cc[i] = t;
else if(cc[i] < t) cc[i]++;
if(i % 4 == 3) {
int t = 64 * cc[i-3] + 16 * cc[i-2] * 4 * cc[i-1] + cc[i];
output(t);
}
}
}
컴파일 시 표준 에러 (stderr) 메시지
encoder.cpp: In function 'void encode(int, int*)':
encoder.cpp:35:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i = 0; i < v[0].size(); i++) {
~~^~~~~~~~~~~~~
encoder.cpp:42:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i = 0; i < v[1].size(); i++) {
~~^~~~~~~~~~~~~
encoder.cpp:49:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i = 0; i < v[2].size(); i++) {
~~^~~~~~~~~~~~~
encoder.cpp:57:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i = 0; i < v[3].size(); i++) {
~~^~~~~~~~~~~~~
encoder.cpp:34:5: warning: 't' may be used uninitialized in this function [-Wmaybe-uninitialized]
if(t != 0) {
^~
# | 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... |