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[])
{
int cnt = 0;
for(int i= 0; i < N; i++){
for(int j = 0; j < 8; j+=2){
int a, b;
a = b = 0;
if(M[i] & (1 << j)) a++;
if(M[i] & (1 << (j + 1))) b++;
cnt += 2 * a + b;
}
}
//cout << cnt;
if(cnt > 6 * N){
int cur = 0;
send(0);
send(0);
send(0);
send(0);
for(int i= 0; i < N; i++){
for(int j = 0; j < 8; j+=2){
int a, b;
a = b = 0;
if(M[i] & (1 << j)) a++;
if(M[i] & (1 << (j + 1))) b++;
for(int x = 0; x < 3 - (2 * b + a); x++)
send(cur);
cur++;
}
}
return;
}
int cur = 0;
for(int i= 0; i < N; i++){
for(int j = 0; j < 8; j+=2){
int a, b;
a = b = 0;
if(M[i] & (1 << j)) a++;
if(M[i] & (1 << (j + 1))) b++;
// cout << a << ' ' << b << "\n";
for(int x = 0; x < 2 * b + a; ++x)
send(cur);
// cout << cur;
cur++;
}
}
}
#include "decoder.h"
#include "decoderlib.h"
#include <bits/stdc++.h>
using namespace std;
void decode(int N, int L, int x[])
{
int cnt[4 * N];
fill(cnt, cnt + 4 * N, 0);
for(int i = 0; i < L; i++){
// cout << x[i] << ' ';
cnt[x[i]]++;
}
if(cnt[0] >= 4){
cnt[0] -= 4;
for(int i = 0; i < 4 * N; i++){
cnt[i] = 3 - cnt[i];
}
}
int ans[N];
fill(ans, ans + N, 0);
int cur = 0;
for(int i = 0; i < N; i++){
for(int j = 0; j < 8; j += 2){
ans[i] += cnt[cur] * (1 << (j));
cur++;
}
output(ans[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... |