Submission #771315

#TimeUsernameProblemLanguageResultExecution timeMemory
771315iulia13Parrots (IOI11_parrots)C++14
81 / 100
5 ms1228 KiB
#include <bits/stdc++.h> #include "encoder.h" #include "encoderlib.h" using namespace std; const int N = 513; void encode(int n, int a[]) { int cnt = 0, i = 0, ok = 0, tot = 3 * 128; while (cnt <= 248 && i < n) { int nr = 128; while(nr) { if (a[i] & nr) ok++; nr /= 2; cnt++; } i++; } while (cnt <= 504 && i < n) { int nr = 128; while (nr) { if (a[i] & nr) { ok += 2; //send(cnt - 256); //send(cnt - 256); } nr /= 2; cnt++; } i++; } if (ok <= tot) ok = 1; else ok = 0; cnt = i = 0; while (cnt <= 248 && i < n) { int nr = 128; while(nr) { if ((a[i] & nr) == nr * ok) send(cnt); nr /= 2; cnt++; } i++; } while (cnt <= 504 && i < n) { int nr = 128; while (nr) { if ((a[i] & nr) == nr * ok) { send(cnt - 256); send(cnt - 256); } nr /= 2; cnt++; } i++; } if (!ok) { send(0); send(0); send(0); send(0); } }
#include <bits/stdc++.h> #include "decoder.h" #include "decoderlib.h" using namespace std; const int N = 513; int vf[N]; int ans[N]; int bits[N]; void decode(int n, int l, int a[]) { for (int i = 0; i < 256; i++) vf[i] = 0; for (int i = 0; i < l; i++) { vf[a[i]]++; } for (int i = 0; i < N; i++) bits[i] = 0; if (vf[0] >= 4) { for (int i = 0; i < N; i++) bits[i] = 1; } for (int i = 0; i < 256; i++) { if (vf[i] & 1) bits[i] |= 1; if (vf[i] & 2) bits[i] |= 1; } int j = 0; for (int i = 0; i < n; i++) { int nr = 128; ans[i] = 0; while (nr) { ans[i] += bits[j] * nr; nr /= 2; j++; } output(ans[i]); } }
#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...