# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
262245 | nandonathaniel | Parrots (IOI11_parrots) | C++14 | 0 ms | 0 KiB |
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 "bits/stdc++.h"
using namespace std;
void encode(int N, int M[])
{
int satu=0,nol=0;
for(int i=0;i<N;i++){
for(int j=0;j<8;j++){
if((1<<j) & M[i])satu++;
else nol++;
}
}
if(satu<nol){
for(int i=0;i<N;i++){
for(int j=0;j<8;j++){
if((1<<j) & M[i])send(j*N+i);
}
}
}
else{
send(0);send(0);
for(int i=0;i<N;i++){
for(int j=0;j<8;j++){
if(!((1<<j) & M[i]))send(j*N+i);
}
}
}
}
#include "decoder.h"
#include "bits/stdc++.h"
using namespace std;
int ans[16],byk[256];
void decode(int N, int L, int X[])
{
memset(byk,0,sizeof(byk));
for(int i=0;i<L;i++)byk[X[i]]++;
memset(ans,0,sizeof(ans));
if(byk[0]>1){
//kita masukkinnya yang mati
for(int i=0;i<256;i++){
if(byk[i])ans[i%N]+=(1<<(i/N));
}
for(int i=0;i<N;i++)ans[i]=255-ans[i];
}
else{
for(int i=0;i<256;i++){
if(byk[i])ans[i%N]+=(1<<(i/N));
}
}
for(int i=0;i<N;i++)output(ans[i]);
}