이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "encoder.h"
#include "encoderlib.h"
#include <bits/stdc++.h>
using namespace std;
int append( int x, int i ){
return 100*x+i;
}
void encode( int N, int M[] ){
/* IDEA 4 :
Generate 'matrix' where rows are the numbers themselves.
Foreach 1 in the matrix : ( xi, yi )
0 <= xi < 32 0 <= yi < 8
represent pair( xi, yi ) as [ xxxxx yyy ]
*/
// cout << endl << "ENCODER" << endl;
int mtx[N] = {};
for(int i=0;i<N;i++){
for(int j=0;j<8;j++) mtx[i] |= M[i] & ( 1 << j );
}
vector <int> pairs;
// for(int i=0;i<N;i++) cout << bitset<8>(mtx[i]) << endl;
// cout << endl;
for(int i=0;i<N;i++) for(int j=0;j<8;j++) if( mtx[i] & ( 1 << j ) ) pairs.push_back( ( i << 3 ) | j );
// for(int i=0;i<pairs.size();i++) cout << bitset<8>(pairs[i]) << endl;
for(int i=0;i<pairs.size();i++) send( pairs[i] );
}
#include "decoder.h"
#include "decoderlib.h"
#include <bits/stdc++.h>
using namespace std;
void decode( int N, int L, int X[] ){
/* IDEA 4 :
Generate 'matrix' where rows are the numbers themselves.
Foreach 1 in the matrix : ( xi, yi )
0 <= xi < 32 0 <= yi < 8
represent pair( xi, yi ) as [ xxxxx yyy ]
*/
// cout << endl << "DECODER" << endl;
int mtx[N] = {};
for(int i=0;i<L;i++){
int xi = 0, yi = 0;
for(int j=7;j>=3;j--) xi |= X[i] & ( 1 << j );
xi >>= 3;
for(int j=2;j>=0;j--) yi |= X[i] & ( 1 << j );
mtx[xi] |= 1 << yi;
// cout << xi << ' ' << yi << endl;
}
// for(int i=0;i<N;i++) cout << bitset<8>(mtx[i]) << endl;
for(int i=0;i<N;i++) output(mtx[i]);
}
컴파일 시 표준 에러 (stderr) 메시지
encoder.cpp: In function 'void encode(int, int*)':
encoder.cpp:37:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=0;i<pairs.size();i++) send( pairs[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... |