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"
void encode(int n, int A[]){
const int nn = 32;
const int LOG = 8;
int on = 0,zr = 0;
for(int i = 0;i<n;i++){
for(int j = 0;j<LOG;j++){
if(A[i] & (1<<j))on++;
else zr++;
}
}
if(on <= zr){
for(int i = 0;i<n;i++){
for(int j = 0;j<LOG;j++){
if(A[i] & (1<<j)){
if(i < nn)send(j * nn + (i));
else {
send(j * nn + (i -nn));
send(j * nn + (i -nn));
}
}
}
}
}else{
send(0);
send(0);
send(0);
send(0);
for(int i = 0;i<n;i++){
for(int j = 0;j<LOG;j++){
if(!(A[i] & (1<<j))){
if(i < nn)send(j * nn + (i));
else {
send(j * nn + (i -nn));
send(j * nn + (i -nn));
}
}
}
}
}
}
#include "decoder.h"
#include "decoderlib.h"
#include <bits/stdc++.h>
using namespace std;
void decode(int n, int l, int A[]){
const int nn = 32;
unordered_map<int,int> mp;
for(int i = 0;i<l;i++){
mp[A[i]]++;
}
bool flip = (mp[0] > 3);
if(flip)mp[0] -= 4;
int res[n] = {0};
for(auto p : mp){
int a = p.first;
int b = p.second;
if(b == 1 || b == 3)res[a % nn] |= (1 << (a/nn));
if(b == 2 || b == 3)res[a % nn + nn] |= (1 << (a/nn));
}
for(int i = 0;i<n;i++){
if(flip)res[i] = 255 - res[i];
output(res[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... |