This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#include "encoder.h"
#include "encoderlib.h"
using namespace std;
void encode(int n, int arr[])
{
vector<int> bits;
for(int i = 0; i < n; i ++ ){
for(int j = 0; j < 8 ; j ++ ){
if((arr[i] & (1 << j))){
bits.push_back(1);
}
else{
bits.push_back(0);
}
}
}
for(int i = 0; i < bits.size(); i ++ ){
if(bits[i] == 1)
send(i);
}
}
/*
void decode(int n, int k, int x[]){
vector<int> ret_bits(n * 8);
for(int i = 0; i < k ;i ++ )
ret_bits[x[i]] = 1;
int L, R;
int sum;
for(int i = 0; i < n; i ++ ){
L = i * 8;
R = L + 8;
vector<int> p;
for(int j = L; j < R; j ++ ){
p.push_back(ret_bits[j] % 2);
}
sum = 0;
for(int bit = 0; bit < 8; bit ++ )
sum += p[bit] * (1 << bit);
output(sum);
}
}
*/
#include <bits/stdc++.h>
#include "decoder.h"
#include "decoderlib.h"
using namespace std;
void decode(int n, int k, int x[]){
vector<int> ret_bits(n * 8);
for(int i = 0; i < k ;i ++ )
ret_bits[x[i]] = 1;
int L, R;
int sum;
for(int i = 0; i < n; i ++ ){
L = i * 8;
R = L + 8;
vector<int> p;
for(int j = L; j < R; j ++ ){
p.push_back(ret_bits[j] % 2);
}
sum = 0;
for(int bit = 0; bit < 8; bit ++ )
sum += p[bit] * (1 << bit);
output(sum);
}
}
Compilation message (stderr)
encoder.cpp: In function 'void encode(int, int*)':
encoder.cpp:20:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i = 0; i < bits.size(); 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... |