# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
64513 | IvanC | Parrots (IOI11_parrots) | C++17 | 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 "encoderlib.h"
#include <bits/stdc++.h>
using namespace std;
void enconder_utility(int qtd_bits,int pos,int number){
vector<int> pos_representation,number_representation;
int manda[3] = {1,2,4};
int comeca[3] = {0,3,6};
for(int i = 0;i<qtd_bits;i++){
if(pos & (1 << i)) pos_representation.push_back(1);
else pos_representation.push_back(0);
}
for(int i = 0;i < 8;i++){
if(number & (1 << i)) number_representation.push_back(1);
else number_representation.push_back(0);
}
number_representation.push_back(0);
for(int vez = 0;vez<3;vez++){
int vai_mandar = 0;
int qual_pot = 1;
for(int i = 0;i<pos_representation.size();i++){
vai_mandar += qual_pot*pos_representation[i];
qual_pot *= 2;
}
for(int i = comeca[vez];i < comeca[vez] + 3;i++){
vai_mandar += qual_pot*number_representation[i];
qual_pot *= 2;
}
for(int quanto = 0;quanto<manda[vez];quanto++) send(vai_mandar);
}
}
void enconde(int N,int M[]){
int qtd_bits = 0;
for(int i = 0;(1 << i) < N;i++) qtd_bits = i + 1;
for(int i = 0;i<N;i++){
enconder_utility(qtd_bits,i,M[i]);
}
}
#include "decoder.h"
#include "decoderlib.h"
#include <bits/stdc++.h>
using namespace std;
void decode(int N, int L, int X[]){
map<int,int> mapa[65];
int ANS[65];
memset(ANS,0,sizeof(ANS));
int qtd_bits = 0;
for(int i = 0;(1 << i) < N;i++) qtd_bits = i + 1;
for(int i = 0;i < L;i++){
int pos = X[i] & ((1 << qtd_bits) - 1);
int outros_bits = (X[i] >> qtd_bits);
mapa[pos][outros_bits]++;
}
for(int i = 0;i<N;i++){
for(auto it : mapa[i]){
int outros_bits = it.first,freq = it.second;
if(freq & 1) ANS[i] += outros_bits;
if(freq & 2) ANS[i] += outros_bits*8;
if(freq & 4) ANS[i] += outros_bits*64;
}
}
for(int i = 0;i<N;i++) output(ANS[i]);
}