# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
926503 | hotboy2703 | 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 "decoder.h"
#include "decoderlib.h"
#include "encoder.h"
#include "encoderlib.h"
#include<bits/stdc++.h>
using namespace std;
const int maxn = 64;
const int maxv = 256;
int h[maxn][maxv];
int f[maxv], ans[maxn];
int ptr = 0;
void init(){
memset(f, 0, sizeof(f));
memset(ans, 0, sizeof(ans));
ptr = 0;
mt19937 rng(69);
for(int i = 0; i < 64; i++){
for(int j = 0; j < 256; j++){
h[i][j] = j;
}
shuffle(h[i], h[i] + maxv, rng);
}
}
void send_bit(int x){
// cout<<"SEND BIT "<<x<<' '<<ptr<<endl;
if(x && ptr < maxv)send(ptr);
else ptr++;
}
void encode(int N, int M[])
{
init();
int cnt1 = 0;
for(int i = 0; i < N; i++)cnt1 += __builtin_popcount(h[i][M[i]]);
int sw = 0;
if(cnt1 < N*4){
sw = 1;
send_bit(0);
}
else send_bit(1);
for(int i = 0; i < N; i++){
for(int j = 0; j < 8; j++){
send_bit((h[i][M[i]]>>j&1)^sw);
}
}
}