Submission #39301

#TimeUsernameProblemLanguageResultExecution timeMemory
39301tjd229Parrots (IOI11_parrots)C++11
98 / 100
17 ms2384 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; int M1[15 * 64]; int M2[15 * 64]; int p1 = 0; int p2 = 0; for (i = 0; i < n; i++){ bit = bit8; for (j = 0; j < 8; j++, bit >>= 1, ix++) if (bit&M[i]) M1[p1++] = ix; else M2[p2++] = ix; } for (ix=0; i < N; i++){ bit = bit8; for (j = 0; j < 8; j++, bit >>= 1, ix++) if (bit&M[i]){ M1[p1++] = ix; M1[p1++] = ix; } else{ M2[p2++] = ix; M2[p2++] = ix; } } for (i = 0; i < 4;i++) M2[p2++]=0; if (p2 < p1) for (i = 0; i < p2; i++) send(M2[i]); else for (i = 0; i < p1; i++) send(M1[i]); }
#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; int c = 0; for (i = 0; i < L; i++) cnt[X[i]]++; if (cnt[0] & 4) c = 255; 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^c); } for (N *= 8; i < N;){ recover = 0; for (j = 0; j < 8; j++, i++){ recover <<= 1; if (cnt[i-256] & 2) recover += 1; } output(recover^c); } }
#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...