| # | Time | Username | Problem | Language | Result | Execution time | Memory | 
|---|---|---|---|---|---|---|---|
| 934680 | tamyte | 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 <vector>
void decode(int N, int L, int X[])
{
  int i;
  std::vector<std::vector<int>> res(N, std::vector<int>(2, -1));
  for(i=0; i<L; i++) {
    int num = 0;
    for (int j = (1 << 4); j <= X[i]; j <<= 1) {
        if (j & X[i]) {
            num += (j >> 4);
        }
    }
    int idx = 0;
    for (int j = 0; j < 4; ++j) {
        if ((1 << j) & X[i]) {
            idx += (1 << j);
        }
    }
//    std::cout << idx << " " << num << " <- " << X[i] << "\n";
    if (res[idx][0] != -1) {
        if (res[idx][0] == num) {
            std::swap(res[idx][0], res[idx][1]);
        }
    } else {
        res[idx][0] = num;
    }
  }
  for (int i = 0; i < N; ++i) {
    if (res[i][0] == -1) res[i][0] = 0;
    if (res[i][1] == -1) res[i][1] = 0;
    int num = ((res[i][0] << 4) + res[i][1]);
//    std::cout << i << ": " << res[i][0] << " " << (res[i][1] << 4) << "\n";
    output(num);
  }
}
