Submission #1112758

#TimeUsernameProblemLanguageResultExecution timeMemory
1112758julia_08Parrots (IOI11_parrots)C++17
81 / 100
6 ms1320 KiB
#include "encoder.h"
#include "encoderlib.h"

#include <bits/stdc++.h>
using namespace std;

void solve(int k, int i){

  int c = k % 10, b = (k / 10) % 10, a = k / 100;

  int qtd_a = a / 4, qtd_b = b / 4, qtd_c = c / 4;

  for(int j=0; j<qtd_a; j++){
    int x = i * (1 << 3) + 0 + 4;

    send(x);
  }

  for(int j=0; j<(a % 4); j++){
    send(i * (1 << 3) + 0 + 0);
  }

  for(int j=0; j<qtd_b; j++){
    int x = i * (1 << 3) + 1 + 4;

    send(x);
  }

  for(int j=0; j<(b % 4); j++){
    send(i * (1 << 3) + 1 + 0);
  }

  for(int j=0; j<qtd_c; j++){
    int x = i * (1 << 3) + 2 + 4;

    send(x);
  }

  for(int j=0; j<(c % 4); j++){
    send(i * (1 << 3) + 2 + 0);
  }

}

void encode(int n, int m[]){

  for(int i=0; i<n; i++){
    solve(m[i], i);
  }

}
#include "decoder.h"
#include "decoderlib.h"

#include <bits/stdc++.h>
using namespace std;

void decode(int n, int l, int x[]){

  vector<vector<int>> id(n);

  for(int i=0; i<l; i++){
    id[x[i] >> 3].push_back(x[i] - ((x[i] >> 3) * (1 << 3))); // fica so 4 bits
  }

  for(int i=0; i<n; i++){

    vector<int> dig(3, 0);

    for(auto k : id[i]){
      int alg = k - ((k >> 2) * (1 << 2));

      if((k >> 2) == 1) dig[alg] += 4;
      else dig[alg] += 1;

    }

    // cout << dig[0] * 100 + dig[1] * 10 + dig[2] << endl;

    output(dig[0] * 100 + dig[1] * 10 + dig[2]);

  }


}
#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...