Submission #345791

#TimeUsernameProblemLanguageResultExecution timeMemory
345791casperwangParrots (IOI11_parrots)C++14
92 / 100
63 ms1828 KiB
#include "encoder.h"
#include "encoderlib.h"
#include <bits/stdc++.h>
using namespace std;

void encode(int N, int M[]) {
  const int C = 10;
  int p[C+1][C+1][C+1][C+1];
  int k = 0;
  for (int a = 0; a <= C; a++)
    for (int b = 0; b <= C; b++)
      for (int c = 0; c <= C; c++)
        for (int d = 0; d <= C; d++)
          if (a+b+c+d == C) p[a][b][c][d] = k++;
          else p[a][b][c][d] = -1;

  for (int i = 0; i < N; i++) {
    for (int a = 0; a <= C; a++) {
      for (int b = 0; b <= C; b++) {
        for (int c = 0; c <= C; c++) {
          for (int d = 0; d <= C; d++) {
            if (p[a][b][c][d] == M[i]) {
              for (int j = 0; j < b; j++) send(i*4+1);
              for (int j = 0; j < c; j++) send(i*4+2);
              for (int j = 0; j < d; j++) send(i*4+3);
            }
          }
        }
      }
    }
  }
}
#include "decoder.h"
#include "decoderlib.h"
#include <bits/stdc++.h>
#define All(x) x.begin(), x.end()
using namespace std;
template <class T> void pary(T L, T R) { while (L != R) cerr << *L << " \n"[++L==R]; }

void decode(int N, int L, int X[]) {
  const int C = 10;
  int p[C+1][C+1][C+1][C+1];
  int k = 0;
  for (int a = 0; a <= C; a++)
    for (int b = 0; b <= C; b++)
      for (int c = 0; c <= C; c++)
        for (int d = 0; d <= C; d++)
          if (a+b+c+d == C) p[a][b][c][d] = k++;
          else p[a][b][c][d] = -1;

  vector <int> ans(N);
  vector <vector<int>> cnt(N);
  for (int i = 0; i < N; i++)
    cnt[i].resize(4);
  for (int i = 0; i < L; i++) {
    int j = X[i] / 4, k = X[i] % 4;
    cnt[j][k]++;
  }
  for (int i = 0; i < N; i++) {
    int o = C - cnt[i][1] - cnt[i][2] - cnt[i][3];
    ans[i] = p[o][cnt[i][1]][cnt[i][2]][cnt[i][3]];
    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...