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 "encoder.h"
#include "encoderlib.h"
#include <bits/stdc++.h>
using namespace std;
void encode(int N, int M[])
{
vector<int> bits;
int i, j;
for(i=0; i<N; ++i)
for(j=0; j<8; ++j)
bits.push_back((M[i] >> j)&1);
int cnt = 0;
for(i=0; 2*i<bits.size(); ++i)
{
int a, b;
a = bits[2*i];
b = bits[2*i+1];
if(a == 0) cnt += 1;
if(b == 0) cnt += 2;
}
bool rev = (cnt > 6*N);
for(i=0; 2*i<bits.size(); ++i)
{
int a, b;
a = bits[2*i];
b = bits[2*i+1];
if(a == rev) send(i);
if(b == rev)
{
send(i);
send(i);
}
}
if(rev)
{
send(0); send(0); send(0); send(0);
}
}
#include "decoder.h"
#include "decoderlib.h"
#include <bits/stdc++.h>
using namespace std;
static int cnt[300];
void decode(int N, int L, int X[])
{
memset(cnt, 0, sizeof(cnt));
int i, j;
for(i=0; i<L; ++i) ++cnt[X[i]];
bool rev = 0;
if(cnt[0] >= 4) rev = 1, cnt[0] -= 4;
vector<int> bits(8*N, rev ^ 1);
for(i=0; i<4*N; ++i)
{
if(cnt[i] & 1) bits[2*i] = rev;
if(cnt[i] & 2) bits[2*i+1] = rev;
}
for(i=0; i<N; ++i)
{
int x = 0;
for(j=0; j<8; ++j)
x += (1<<j) * bits[8*i+j];
output(x);
}
}
Compilation message (stderr)
encoder.cpp: In function 'void encode(int, int*)':
encoder.cpp:16:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(i=0; 2*i<bits.size(); ++i)
~~~^~~~~~~~~~~~
encoder.cpp:28:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(i=0; 2*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... |