# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
573544 | Deepesson | Parrots (IOI11_parrots) | C++17 | 8 ms | 1356 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.
/**Encoder**/
#include <bits/stdc++.h>
//#include "encoder.h"
//#include "encoderlib.h"
void send(int a);
std::string enviar;
int qtdzeros,qtduns;
void inserezero(void){
if(!qtdzeros)assert(0);
--qtdzeros;
enviar+="0";
}
void insereum(void){
if(!qtduns)assert(0);
--qtduns;
enviar+="1";
}
std::string plano;
void codificar_e_enviar(){
//std::cout<<enviar<<" envia\n";
int cur=0;
int count=0;
for(auto&x:enviar){
if(x=='1'){
++cur;
}else {send(cur);++count;}
}
}
void encode(int N, int M[])
{
qtduns=256;
qtdzeros=N*9;
enviar="";
plano="";
int count = 0;
for(int i=0;i!=N;++i){
for(int j=0;j!=8;++j){
bool valor = (bool)((M[i]^145)&(1<<j));
count+=valor;
plano.push_back(valor+48);
}
}
if(count>256){
insereum();
}else inserezero();
for(int i=0;i!=plano.size();++i){
bool valor = plano[i]-48;
if(count>256){
valor=!valor;
}
if(valor)insereum();else inserezero();
}
codificar_e_enviar();
}
/**Decoder**/
#include <bits/stdc++.h>
//#include "decoder.h"
//#include "decoderlib.h"
void output(int b);
void decode(int N, int L, int X[])
{
int count[256]={};
for(int i=0; i<L; i++) {
count[X[i]]++;
}
std::string trueseq;
int cur=0;
while(cur!=256){
if(count[cur]){
--count[cur];
trueseq.push_back('0');
}else {
++cur;
trueseq.push_back('1');
}
}
// std::cout<<"Recebe "<<trueseq<<"\n";
cur=1;
bool inverte = trueseq[0]-48;
for(int i=0;i!=N;++i){
int ans=0;
for(int j=0;j!=8;++j){
int p = (1<<j);
bool k = trueseq[cur]-48;
if(inverte)k=!k;
if(k)ans+=p;
++cur;
}
output(ans^145);
}
}
Compilation message (stderr)
# | 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... |