Submission #39267

#TimeUsernameProblemLanguageResultExecution timeMemory
39267tjd229Parrots (IOI11_parrots)C++11
81 / 100
11 ms2432 KiB
#include "encoder.h" #include "encoderlib.h" void encode(int N, int M[]) { int i,j; int ix = 0; int bit8 = 1 << 7; int bit; int n = N < 32 ? N : 32; for (i = 0; i < n; i++){ bit = bit8; for (j = 0; j < 8; j++, bit >>= 1, ix++) if (bit&M[i]) send(ix); } for (ix=0; i < N; i++){ bit = bit8; for (j = 0; j < 8; j++, bit >>= 1, ix++) if (bit&M[i]){ send(ix); send(ix); } } }
#include "decoder.h" #include "decoderlib.h" void decode(int N, int L, int X[]) { int i,j; int cnt[256] = { 0 }; int recover; int n = N < 32 ? N : 32; for (i = 0; i < L; i++) cnt[X[i]]++; for (i = 0,n*=8; i < n;){ recover = 0; for (j = 0; j < 8; j++, i++){ recover <<= 1; if (cnt[i]&1) recover += 1; } output(recover); } for (N *= 8; i < N;){ recover = 0; for (j = 0; j < 8; j++, i++){ recover <<= 1; if (cnt[i] & 2) recover += 1; } output(recover); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...