Submission #1140433

#TimeUsernameProblemLanguageResultExecution timeMemory
1140433josephtenorioParrots (IOI11_parrots)C++20
96 / 100
6 ms840 KiB
#include "encoder.h"
#include "encoderlib.h"
#include <bits/stdc++.h>

using namespace std;

void encode(int N, int m[]) {
  int sup = 64 - 1;
  int enviar = 0;
  vector<pair<int, int>> ax = {
    {-1, -1},
    {0, 3},
    {4, 12},
    {13, 28},
    {29, 53},
    {54, 89},
    {90, 138},
    {139, 202},
    {203, 283}
  };
  for (int t1 = 0; t1 < N; t1 ++) {
    int mes = sup;
    mes <<= 2;
    for (int t2 = 1; t2 <= 8; t2 ++) {
      if (ax[t2].first <= m[t1] && m[t1] <= ax[t2].second) {
        int ax2 = m[t1] - ax[t2].first;
        int d1 = ax2 % (t2 + 1);
        int d2 = (ax2 - d1) / (t2 + 1);
        for (int t3 = 0; t3 < t2; t3 ++) {
          send(mes + (d2? 2:0) + (d1? 1:0));
          d1 = max(0, d1 - 1);
          d2 = max(0, d2 - 1);
        }
        break ;
      }
    }
    //if (m[t1] <= 3) {
    //  send(mes + m[t1]);
    //}
    sup --;
  }
  return ;
}
#include "decoder.h"
#include "decoderlib.h"
#include <bits/stdc++.h>

using namespace std;

void decode(int N, int L, int X[]) {
  vector<pair<int, int>> ax = {
    {-1, -1},
    {0, 3},
    {4, 12},
    {13, 28},
    {29, 53},
    {54, 89},
    {90, 138},
    {139, 202},
    {203, 283}
  };
  vector<int> ns(L);
  for (int t1 = 0; t1 < L; t1 ++) {
    ns[t1] = X[t1];
  }
  sort(ns.rbegin(), ns.rend());
  int sup = 64 - 1, ind = 0;
  for (int t1 = 0; t1 < N; t1 ++) {
    int d1 = 0, d2 = 0, base = 1;
    while (ind < L && ns[ind] / 4 == sup) {
      if (ns[ind] % 4 == 3) {
        d1 ++;
        d2 ++;
      } else if (ns[ind] % 4 == 2) {
        d2 ++;
      } else if (ns[ind] % 4 == 1) {
        d1 ++;
      } else {
        
      }
      base ++;
      ind ++;
    }
    sup --;
    output(ax[base - 1].first + d2*base + d1);
  }
  return ;
}
#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...