Submission #766347

#TimeUsernameProblemLanguageResultExecution timeMemory
766347anaduguleanuParrots (IOI11_parrots)C++14
98 / 100
8 ms1360 KiB
#include "encoder.h" #include "encoderlib.h" #include <iostream> #include <vector> using namespace std; void encode(int N, int M[]) { vector <int> v1, v2 = {255, 255, 255, 255}; for (int i = 0; i < N; i++) for (int j = 0; j < 4; j++) { bool bit1 = M[i] & (1 << (2 * j)); bool bit2 = M[i] & (1 << (2 * j + 1)); int val = bit1 + 2 * bit2; int pos = 4 * i + j; for (int k = 0; k < val; k++) v1.push_back(pos); for (int k = 0; k < 3 - val; k++) v2.push_back(pos); } if (v1.size() < v2.size()) for (auto it : v1) send(it); else for (auto it : v2) send(it); }
#include "decoder.h" #include "decoderlib.h" #include <iostream> #include <vector> using namespace std; void decode(int N, int L, int X[]) { vector <int> freq(260, 0); for (int i = 0; i < L; i++) freq[X[i]]++; int ok; if (freq[255] < 4) ok = 0; else { ok = 1; freq[255] = freq[255] - 4; } for (int i = 0; i < N; i++) { int val = 0; for (int j = 0; j < 4; j++) { int aux = freq[4 * i + j]; if (aux == 1) val = val | (1 << (2 * j)); else if (aux == 2) val = val | (1 << (2 * j + 1)); else if (aux == 3) { val = val | (1 << (2 * j)); val = val | (1 << (2 * j + 1)); } } if (ok == 1) val = (~val) & 255; output(val); } }
#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...